• Resolved teolives

    (@teolives)


    I have the following code to autologin users after they have created a profile:

    add_filter( 'registration_redirect', 'ckc_registration_redirect' );
    function ckc_registration_redirect( $registration_redirect ) {
        return home_url('/sample-page/');
    }

    Well, in that case the plug-in doesn’t return any “Last Login” Date…

    Any way to modify the above code or fix the plugin?

    M

    • This topic was modified 6 years, 10 months ago by teolives.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Konstantin Obenland

    (@obenland)

    Hi there!

    Interesting use case. Are you sure they’re are actually logged in after the redirect?

    Unfortunately you can’t update the user meta at the time that filter fires because the user is not created yet. So my best advice would be to hook into the load process of sample-page and update that user option when you have a user ID available.

    Konstantin

    Thread Starter teolives

    (@teolives)

    Ops, my bad, you are right, that code only changes the redirect page upon registration, the code for autologin is the following:

    function tml_new_user_activation( $user_id ) {
    	wp_set_auth_cookie( $user_id );
    }
    add_action( 'register_new_user', 'tml_new_user_activation' );

    That leverages the plugin “Theme My Login” but really just uses “register_new_user”: can I add something there to populate the “last login” column?

    Matteo

    Plugin Author Konstantin Obenland

    (@obenland)

    Absolutely, adding the following will achieve that:

    update_user_meta( $user_id, 'wp-last-login', time() );

    Let me know if that didn’t help.

    Thread Starter teolives

    (@teolives)

    Looks like it’s working! Thanks a lot!

    Matteo

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not tracking auto login’ is closed to new replies.