Why am I getting users with @example.com email address into my Wordpress?

I have it configured such that an email address is required. A lot of users have @example.com in their username, but a real e-mail address provided in the user_email parameter, which is fine. However, some users have both @example.com in their username and their user_email (the same string, pretty long). How does that happen?

Is there any way I can tap into the registration process, in the case where an email is not available, and require sending an activation email to whatever the user inserts?

Merry xmas!

Regards,
Gus

Answers

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited December 2016
    Hi Gus,

    unfortunately not all social networks provide the user's email address, and on some social networks the users can decide not to share it during the login. So there is no guarantee that the user's email address is always available.

    In the Social Login settings in your WordPress admin area you can see this setting:
    If the user's social network profile has no email address, should we ask the user to enter it manually?

    Select the following option to have the plugin ask the user for his email address in case it's not provided from the social network:
    Yes, require the user to enter his email address manually and display this message:

    If you select the other option
    No, simplify the registration by automatically creating a placeholder email
    Then the plugin will create the example.com placeholder email addresses.
  • I have that setting already enabled, see:
    image

    Still get a lot of example.com users as you can see below. Some have both @example.com username and email address, some have @example.com username and a real email address:
    image


  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited December 2016
    Hello,

    is the email address being used as username intentional?

    Regards,
  • Yes. For our system we use email address as the user name. Does that matter?
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    I think the first thing that we should have a look at are the users that have a correct email address, but nevertheless still the example.com username.

    Are you using a filter/hook to setup the user's email as username?
    Could you post that filter/hook here?
  • edited December 2016
    Here are all my filters/hooks for the plugin

    // This function will be called after Social Login has added a new user add_action('oa_social_login_action_after_user_insert', function($user_data, $identity) { $url = home_url('/#welcome'); wp_set_current_user( $user_data->ID, $user_data->user_login ); wp_set_auth_cookie( $user_data->ID ); // At this point the user has successfully activated, send email. $user = new WP_User($user_data->ID); $name = trim($user->first_name . " " . $user->last_name); wrap_auth_user_activated($user->ID, $user->user_email, $name); wp_redirect($url); exit(); }, 10, 2);

    // Use the email address as user login also. add_filter('oa_social_login_filter_new_user_fields', function($user_fields) { if (!empty ($user_fields['user_email'])) { if (!username_exists($user_fields['user_email'])) { $user_fields['user_login'] = $user_fields['user_email']; } } return $user_fields; });
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited December 2016
    Hello,

    the plugin has a hook oa_social_login_action_on_user_enter_email that is triggered when the user manually updates his email address (@example.com => real email address) after having connected with a social network that does not provide an email address.

    You should add a function like this:

    add_action('oa_social_login_action_on_user_enter_email', function($user_id, $user_data, $old_user_email) { // Change username to new email address wp_update_user (array ('ID' => $user_data->ID, 'user_login' => $user_data->user_email)); // Send activation email $user = new WP_User($user_data->ID); $name = trim($user->first_name . " " . $user->last_name); wrap_auth_user_activated($user->ID, $user->user_email, $name); }, 10, 2)

    This basically changes the user's login to his email address once he has entered his real email address and then sends the activation email. This code is untested, please test it after having added it.
  • That will help make sure that I get the email as the username.
    Still I am not sure if that solves the case where I am getting where the user_email and username is the @example.com address. In most cases I have the correct user_email but an @example.com username, which is fine. The main problem is when the user_email is wrong, i.e. something not entered by the user.

    Is there any case where the user can bypass entering their email?
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Hello,

    Is there any case where the user can bypass entering their email?

    It works like that:

    1. The user logs in and a new account is created 2. The plugin checks if it could retrieve the users email address 3. If not the user is prompted to enter his email address 4. If the user cancels this prompt, then his account is removed.

    So the users for which you have an @example.com email addresses are users which are still on step 3.
    Theses user might come back later and then they will be prompted once again to enter their email address.

    It's also possible that the user will not come back. I think it's safe to remove the accounts if they are more than a week old.
  • Thank you, I understand. The weird thing is that some users from @example.com email address are actively doing things on my site that only properly registered and logged in users should be capable of doing.

Welcome!

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.