We are glad to welcome you to our Community Support Forums!
These forums are your way of communicating with the community of people developing and using tools provided by the OneAll platform.
The forums are run by the community and moderated by the OneAll team during office hours. Please stick to technical issues - and remember, no confidential information - these are public forums!

email new user Hook

edited July 14 in WordPress
AFter a user registers for the first time using Social Login. Is there a hook I can use to send the user an email?

Comments

  • Hi Dan,

    which CMS (WordPress, Drupal, Joomla ... ) are you using?
  • Wordpress
  • edited July 14
    Hi Dan,

    you can use something like this:

    function custom_oa_social_login_action_after_user_insert($user_data, $identity)
    {
    if( ! empty ($user_data->user_email) && strpos($user_data->user_email, 'example') === false)
    {
    //The blogname option is escaped with esc_html on the way into the database
    $blogname = wp_specialchars_decode (get_option ('blogname'), ENT_QUOTES);

    //Setup Mail
    $recipient = $user_data->user_email;
    $subject = 'Welcome to '.$blogname;
    $body = "Welcome to our blog\r\n\r\n";
    $body .= "Your username: ".$user_data->user_login;

    //Send Mail
    @wp_mail ($recipient, $subject, $body);

    }
    }
    add_action('oa_social_login_action_after_user_insert', 'custom_oa_social_login_action_after_user_insert', 10, 2);


    I haven't tested the code, so please make sure that it works correctly after having added it.
Sign in with your OneAll account to take part in the discussion.