• Using theme my login plugin i have put passowrd at during the registration. I want that after a user registers he automatically login and he should be redirected to profile page.

Viewing 13 replies - 31 through 43 (of 43 total)
  • I used the following code to create a successful registration>auto-login>redirect to page-x; however, this conflicted with Register Plus Redux plugin in two ways: 1) I am not receiving notifications of new users; and 2) New user profiles do not contain the custom field information that was required on registration

    <?php
    function tml_new_user_registered( $user_id ) {
        wp_set_auth_cookie( $user_id, false, is_ssl() );
        wp_redirect( 'https://mysite.com/congrats' );
        exit;
    }
    add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
    ?>

    How can i let the other plugin finish it’s business before this redirection begins…

    Of all the modules for WP, it’s unusual that there isn’t a plugin for auto-login or reg redirect

    I found an auto-login plugin, worked perfectly, no conflicts

    https://blog.coderaustralia.com/wordpress-plugins/wordpress-auto-login

    I also am not getting the new user notification sent, and the plugin above does not work for me either (it just goes to a blank page, and doesn’t display the custom TML welcome message from the custom TML welcome email module.

    Jeff, is there any way you could modify this code to allow the custom welcome email to be sent?

    function tml_new_user_registered( $user_id ) {
    	wp_set_auth_cookie( $user_id, false, is_ssl() );
    	wp_redirect( wp_get_referer() );
    	exit;
    }
    add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
    
    function tml_register_form() {
    	wp_original_referer_field( true, 'previous' );
    }
    add_action( 'register_form', 'tml_register_form' );

    Sorry, actually the code used is this:

    function tml_new_user_registered( $user_id ) {
    	wp_set_auth_cookie( $user_id, false, is_ssl() );
    	$referer = remove_query_arg( array( 'action', 'instance' ), wp_get_referer() );
    	wp_redirect( $referer );
    	exit;
    }
    add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
    
    function tml_register_form() {
    	wp_original_referer_field( true, 'previous' );
    }
    add_action( 'register_form', 'tml_register_form' );

    The main point is that using that code in your custom php for TML, the welcome email doesn’t send.

    Thanks!

    Try adding a higher priority to the function:

    add_action( 'tml_new_user_registered', 'tml_new_user_registered', 11 );

    Thank you very much Jeff, that did the trick!

    I created a post auto login plugin. Once an account is created the user is automatically logged in when the plugin is activated. No php or theme coding needed.

    https://is.ca/post-register-auto-login/

    Maybe you cane help me on this topic.

    I have setup theme my login on a page with two languages (english and german) – everything works well ?? only if you are update your profile page on the german page it redirects to the english page after pressing the “safe profile” button.

    The url before press the “Profil speichern” button looks like this
    …./de/login/?action=profile

    then after the update
    …./login/?action=profile&updated=true

    Maybe there is a little workaround for this

    None of the above hacks works …

    Trying to get the user logged in right after registration and redirected to the page he originally came from.

    The user gets logged in, but the plugin stubbornly redirects to the Profile page!

    This is horrible, as I do NOT want my users to EVER get to see that profile page.

    How can this finally get solved please?

    Thanks!

    Yes, I can’t seem to get this to work either. I tried adding the following code, as per Jeff’s example, but I can’t seem to get it to work. I’ve posted my code below:

    Contents of wp-content/plugins/theme-my-login-custom.php:

    function auto_login_after_user_registration( $user_id ) {
        wp_set_auth_cookie( $user_id, false, is_ssl() );
        wp_redirect( admin_url( 'profile.php' ) );
        exit;
    }
    add_action( 'tml_new_user_registered', 'auto_login_after_user_registration', 20 );

    Can anyone help me please?

    The “New User Notification” emails aren’t being delivered to users either, curiously, even without adding this auto-login code. Very strange… Can someone please tell me what’s going on?

    Hi all, I see there’s a lot of people loving to work with this plugin.
    very nice Job Jeff =)

    I have a slighlty different issue:

    1) i want to use the tml redirection module as default settings
    2) But i would like to specify when i need a different redirection for login and registration+auto-login

    Actually i’ve been able with little effort to achieve this on login phase.
    I just pass on querystring a variable “redirect_url”
    then with this little edit on my customized login-form.php

    <?php
    			$redirect_url = $_GET['redirect_url'];
    			if ($redirect_url == ""){
    			?>
    				<input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'login' ); ?>" />
    				<?php }else{ ?>
    				<input type="hidden" name="redirect_to" value="<?php echo $redirect_url; ?>" />
    				<?php } ?>

    it works seamless.

    But i’m not able to achieve the same results on registration-form.php just because it do not auto-log users.

    how could I make users, after registration, to auto-login and redirect in a custom url (passed on querystring to registration template) Only if this is specified, otherwise they will be redirected to default page set on tml redirection module?

    well… the only way i’ve been able to achieve it is using cookies:

    1) in registration-form.php:

    $redirect_url = $_GET['redirect_url'];
    if ($redirect_url != ""){
       setcookie('redirect_url',$redirect_url);
    }

    2) in theme-my-login-custom.php:

    function tml_new_user_registered( $user_id ) {
    
    	wp_set_auth_cookie( $user_id, false, is_ssl() );
    
    	 if (isset($_COOKIE['redirect_url'])) {
    		$redirect_url = $_COOKIE['redirect_url'];
    		setcookie("redirect_url", "", time()-3600);
    		wp_redirect($redirect_url);
    
    		}else{
    		$redirecting_url = site_url('/odontoiatri/login/?action=profile&new_user=1');
    		wp_redirect($redirecting_url);
    		}
    
        exit;
    }
    add_action( 'tml_new_user_registered', 'tml_new_user_registered' );

    if someone has a better way (i’m sure there is) i would like to know =)

Viewing 13 replies - 31 through 43 (of 43 total)
  • The topic ‘Auto login after register and redirect to profile page’ is closed to new replies.