Auto login doesn't work after active Pro Sites plugin

Hi
I found a code to auto login after activate users with activation link on WPMU and it works fine. But after install Pro Sites and active the plugin, users account are activate by click on activation link, but not login to the site and i get a with page with header.

For auto login I used this code in my functions.php:

function auto_login_new_user( $user_id, $email, $meta ) {
    $user = new WP_User( (int) $user_id );
    $creds = array();
    $creds['user_login'] = $user->user_login;
    $creds['user_password'] = $meta['user_pass'];
    $creds['remember'] = true;
    $user = wp_signon( $creds, false );
    wp_set_current_user($user->ID);
    if ( is_wp_error($user) ) {
        echo $user->get_error_message();
    } else {
        // safe redirect to actually login the user - otherwise they would need to manually refresh the page
        // PLUS: this clears the activation confirmation page with the plain text password printed on screen
        wp_safe_redirect( get_home_url() );
        exit;
    }
}
add_action( 'wpmu_activate_user', 'auto_login_new_user', 10, 3 );
  • Kasia Swiderska

    Hello Morteza,

    But after install Pro Sites and active the plugin, users account are activate by click on activation link, but not login to the site and i get a with page with header.

    It looks that there is error there if there is only header showing. Can you enable debug mode to check that error? To enable it, open your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:

    define('WP_DEBUG', true);

    In order to enable the error logging to a file on the server you need to add yet one more similar line:

    define( 'WP_DEBUG_LOG', true );

    In this case the errors will be saved to a debug.log log file inside the /wp-content/directory.

    Depending on whether you want your errors to be only logged or also displayed on the screen you should also have this line there, immediately after the line mentioned above:

    define( 'WP_DEBUG_DISPLAY', false );

    The wp-config.php is located in your WordPress root directory. It’s the same file where the database configuration settings are. You will have to access it by FTP or SFTP in order to edit it. I would need then to see contents of the debug.log file - so please paste it to the text file and attach to post.

    kind regards,
    Kasia

  • Morteza Rezvani

    Hi Ash

    I try with default theme and I nothing changed. I can't understand why it happen. It should be something with "Pro Sites" plugin.

    For clear the issue I put my header.php here:

    <!DOCTYPE html>
    <!--[if lt IE 7]> <html class="no-js ie6 oldie" <?php language_attributes(); ?>> <![endif]-->
    <!--[if IE 7]>    <html class="no-js ie7 oldie" <?php language_attributes(); ?>> <![endif]-->
    <!--[if IE 8]>    <html class="no-js ie8 oldie" <?php language_attributes(); ?>> <![endif]-->
    <!--[if gt IE 8]> <!--> <html <?php language_attributes(); ?>> <!--<![endif]-->
    <head>
    	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    	<meta charset="<?php bloginfo( 'charset' ); ?>" />
    	<meta name="description" content="Keywords">
    	<meta name="author" content="Name">
    	<!--Let browser know website is optimized for mobile-->
    	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
    
    	<link rel="shortcut icon" href="<?php bloginfo('template_url'); ?>/images/favicon.ico" />
    
    	<title><?php the_title( ); ?> - <?php bloginfo( 'name' ); ?></title>
    
    	<?php wp_head(); ?>
    </head>
    <body class="grey lighten-4">
    	<div class="loader">
    		<div class="sppiner">
    			<div class="preloader-wrapper big active">
    				<div class="spinner-layer spinner-blue-only">
    					<div class="circle-clipper left">
    						<div class="circle"></div>
    					</div>
    					<div class="gap-patch">
    						<div class="circle"></div>
    					</div>
    					<div class="circle-clipper right">
    						<div class="circle"></div>
    					</div>
    				</div>
    			</div>
    		</div>
    	</div>
  • Morteza Rezvani

    Hi Kasia Swiderska

    Yes this code auto login your user when they click on activation link, and its work for me when I disabled "Pro Sites" plugin. Even you can redirect users to profile page after activation by change this wp_safe_redirect( get_home_url() ); to wp_safe_redirect( get_home_url() . '/profile' );

    all is good until Pro Sites has been disabled. Exactly after active Pro Site, when users click on activation link, they account has been activated, but auto login does't work and user get a blank page with header.

    This is really strange situation and I can't find any logical reason for this issue :confused:

    Best Regards
    Morteza Rezvani

  • Morteza Rezvani

    Hi Kasia Swiderska

    I found another conflict :tired_face: :tired_face: :tired_face:
    When I start my project, at first I used "Material Design Lite" for my theme. Unfortunately, MDL was conflict with "Support System" plugin. Support system use TinyMCE for front-end ticket editor and MDL has conflict with TinyMCE. So I switch to "MaterializeCSS" frame work.

    Now I found another conflict. I use loader class to create a Preloader for my theme.

    <div class="loader">
    		<div class="sppiner">
    			<div class="preloader-wrapper big active">
    				<div class="spinner-layer spinner-blue-only">
    					<div class="circle-clipper left">
    						<div class="circle"></div>
    					</div>
    					<div class="gap-patch">
    						<div class="circle"></div>
    					</div>
    					<div class="circle-clipper right">
    						<div class="circle"></div>
    					</div>
    				</div>
    			</div>
    		</div>
    	</div>

    This class use some jQuery and JS functions to create Preloader. Without "Pro Sites" plugin my code worked like a charm, but exactly after enable Pro Sites plugin, I get some error and my code break. So I had to remove above tags and create a simple preloader without MaterializeCSS.

    I think I found more conflict with MaterializeCSS in future, but for now, my problem is solved.

    Best Regards
    Morteza Rezvani

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.