Auto login hack block administrative email

Hello,

i use S2memberPro, and i found a hack on internet for an auto-logging after registration.
Unfortunately, this hack block the email confirmation of a new register for the webmaster.

<?php

add_action(‘ws_plugin__s2member_during_configure_user_registration’, ‘s2_auto_login_after_registration’);
function s2_auto_login_after_registration($vars = array())
{
if(is_admin()) return; // Not when an Admin is creating accounts.

      wp_set_auth_cookie($vars['user_id'], FALSE, FALSE); // Log the user in.

      remove_all_filters('login_redirect'); // BuddyPress compatibility.

      if(did_action('login_form_register')) // For `/wp-login.php?action=register` compatibility.
          c_ws_plugin__s2member_login_redirects::login_redirect($vars['login'], $vars['user']);

      $GLOBALS['_s2_auto_login_after_registration_vars'] = $vars; // For Pro Form compatibility.
      add_action('template_redirect', '_s2_auto_login_after_registration', 1);
  }

function _s2_auto_login_after_registration() // Pro Form redirection handler.
{
$vars = $GLOBALS[’_s2_auto_login_after_registration_vars’];
c_ws_plugin__s2member_login_redirects::login_redirect($vars[‘login’], $vars[‘user’]);
}

Do you know why ?

Thanks.

I don’t see where it blocks emails to the webmaster. It does stop the auto-login when the registration is being created by an admin (if(is_admin()) return; // Not when an Admin is creating accounts.).

Thank you for your answer. Maybe I was not enough clear.
When i desactivate the auto login code, confirmation email for a new register is sending to the webmaster.
But if i insert this code in function.php of my wordpress, the confirmation email is never sent. The new register alert by mail only works if i add manually a user in the backoffice.

So, i guess the problem comes from the auto login. Maybe, this hack function stop administrative mail to the webmaster ?

Where precisely are you putting this code?

I’d also suggest you try the slightly revised version of the code that you will find here: https://forums.wpsharks.com/t/sign-in-the-new-user-after-checkout/