TUTORIAL Proper names for users registered with Social Login (e.g. Vkontakte)

3.32K viewsUpdates
1

Not all providers in WordPress Social Login (officially recommended for AnsPress) return proper data. For vk.com provider (russian facebook) it was returning user id as “display name”.

This display name issue can be fixed with simple snippet:

add_action('user_register','d_change_display_name');
function d_change_display_name( $user_id ) {
    $info = get_userdata( $user_id );
	$args = array(
		'ID' => $user_id,
		'display_name' => $info->first_name . ' ' . $info->last_name
	);
    wp_update_user( $args );
}