first and last name in wordpress account

hi all,

we noticed that in wordpress, for users loggin with fb and google, oneall sets username and email. username is set with name and surname. is it possible to set also first and last name in wordpress account? even with some coding

thanks in advance for your cooperation

Best Answer


  • Hi,
    The plugin attempts to do this already (fill in first and last names).
    The difference is that for the username, the plugin searches in several places of the profile for the name fields, whereas it only looks in one place for the first and last names.
    So, the user social profile may not have proper first and last names, but a full name that the username uses.

    You can define a filter action on one of the plugin's event.
    In your functions.php file, you can add something like:
    add_filter ('oa_social_login_filter_new_user_fields', 'fill_names', 10, 1); function fill_names ($user_fields) { // If names are available, return: if (!empty($user_fields['first_name']) AND !empty($user_fields['last_name'])) { return $user_fields; } // We need a full name (else abort): if (empty($user_fields['display_name'])) { return $user_fields; } // Split the full name into first and last (this will not always work): $names = explode (' ', $user_fields['display_name']); if (count ($names) >= 2) { $user_fields['first_name'] = $names[0]; $user_fields['last_name'] = $names[1]; } return $user_fields; }

    Hope this helps.
  • Hi,
    The info above just pointed to the fact that usernames and first/last names can come from different fields, which may or not be present in your profile (ex: Twitter).


Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

Please click on the link below to connect to the forum with your OneAll account.