Skip to content

Instantly share code, notes, and snippets.

@harishankerr
Last active June 16, 2017 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harishankerr/53ec1bfac355dff12f12d2a5e6edbf90 to your computer and use it in GitHub Desktop.
Save harishankerr/53ec1bfac355dff12f12d2a5e6edbf90 to your computer and use it in GitHub Desktop.
/**
* Customize user data for new users registered via WC Social Login
* Example: set a custom role other than "customer" on registration
*/
/**
* Add filters to adjust user data for each active Social Login provider
*/
function sv_wc_social_login_new_user_data_add_filters() {
if ( ! function_exists( 'wc_social_login' ) ) {
return;
}
foreach ( array_keys( wc_social_login()->get_available_providers() ) as $provider ) {
add_filter( 'wc_social_login_' . $provider . '_new_user_data', 'sv_wc_social_login_new_user_data' );
}
}
add_action( 'init', 'sv_wc_social_login_new_user_data_add_filters', 100 );
/**
* Filter the new user data on registration via Social Login
*
* @param array $user_data the data set for the new user at registration
* @return array the updated user data
*/
function sv_wc_social_login_new_user_data( $user_data ) {
$first_name = $profile->get_first_name();
$last_name = $profile->get_last_name();
$user_data['user_login'] = $first_name.$last_name;
return $user_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment