• 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 15 replies - 1 through 15 (of 43 total)
  • It can be done using action hooks.

    Thread Starter Tamojyoti Bose

    (@tamojyoti-bose)

    can u please help me with the hooks.

    Create a file called theme-my-login-custom.php in your plugins directory. Then try adding this to it:

    <?php
    function tml_new_user_registered( $user_id ) {
        wp_set_auth_cookie( $user_id, false, is_ssl() );
        wp_redirect( admin_url( 'profile.php' ) );
        exit;
    }
    add_action( 'tml_new_user_registered', 'tml_new_user_registered' );
    ?>
    Thread Starter Tamojyoti Bose

    (@tamojyoti-bose)

    Jeff, Thanks a lot it worked.

    I believe I will make this a built-in option for a future version. Thanks for the idea.

    HI,I LIKE YOUR THEM SO MUCH, IT MAKES ME FEEL VERY CONVENIENT. CAN YOU TELL ME HOW I CAN MAKE THE USER LOGIN DIRECTLY TO MY HOMEPAGE WITHOUT FILLING IN PROFILE??
    THANKS!
    LINDA DAVIS

    I MEAN LOGIN AFTER REGISTER, THANKS

    Umm, see above.

    Not sure if this is the right thread, but I’m using TML and love it. The site I’ve used it on needs password protection for all pages except the Home page and Login. I’m using a simple check at the top of page templates to see if the user is logged in:

    get_currentuserinfo();
    global $user_ID;
    if ($user_ID == ”)
    {
    header(‘Location: /login/’);
    }

    Login takes them to the TML login page. Problem is, I like how WordPress by default will redirect after login to the page you were intending to view, once you log in. Right now, my header redirect sends them to “login” without a way after that to get back to the page they wanted to see (using TML, I redirect all subscribers to a certain page after login).

    Is there a way to capture the referring url and append it to the /login/? Is is there a better way to get users redirected back where they wanted to go, while still keeping pages password protected this way?

    Jeff Farthing

    (@jfarthing84)

    Try something like this:

    if ( !is_user_logged_in() ) {
        $redirect_to = wp_login_url( $_SERVER['REQUEST_URI'] );
        wp_redirect( $redirect_to );
        exit;
    }
    focus97

    (@focus97)

    You are awesome. Seriously great plugin, and after setting the redirect for subscribers to “referrer”, your script above works beautifully. Just fantastic.

    Hey Jeff,

    I’m a bit late to the party here, but I was curious how the action “tml_new_user_registered” is called? Do I need to do_action anywhere?

    Thanks,

    –d

    EDIT: I’m seeing this has to do with the “Theme My Login” theme… is there any way for me to do something similar with a different theme? Thanks!

    Hi Jeff, I too am using your plugin, which is magnificent. BUT, I can’t seem to get it to redirect to my homepage after registration and stay logged in (steps above already attempted). Can you or someone please please help, i’m getting desperate. Thanks!

    Jeff it’s works for the auto login and redirect using the action hooks as you mentioned. But there is a problem when using this new users are not getting welcome emails and even admin is not getting emails for new user signup.

    Any idea how to fix this?

    Using this function

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

    Is it possible to redirect to the referrer instead of the profile?

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