WordPress.org

Ready to get started?Download WordPress

Forums

redirect after first login only (8 posts)

  1. Ojay
    Member
    Posted 4 years ago #

    Hey there,

    I'm looking to setup a re-direct to a certain page after someone has registered and is logging in for the first time. Any other time they login I need them to end up on the home page, which is easy enough, but I can't think how to achieve re-directing to a different page when someone's logging in after registering for the first time...

    Any ideas? they would be much appreciated!

    cheers

  2. Tosh
    Member
    Posted 4 years ago #

    I'm looking for something similar. Show a pop-up or re-direct a user that's logged in for the first time. In my case I want to direct them to change there password.

  3. Samuel B
    moderator
    Posted 4 years ago #

  4. Tosh
    Member
    Posted 4 years ago #

    That will forward every time instead of just once for new members actually.

    Found this though ...

    http://wordpress.org/support/topic/357901?replies=2

    global $user_ID;
    if( $user_ID ) {
    	$user_info = get_userdata( $user_ID );
    	// If user_registered date/time is less than 48hrs from now
    	// Message will show for 48hrs after registration
    	if ( strtotime( $user_info->user_registered ) < ( time() + 172800 ) )
    		echo 'Welcome, ' . $user_info->display_name . '. Thanks for registering.';
    }

    I tried that, but it shows up even if they have been a member for longer than 48 hours.

  5. ReflectionMedia
    Member
    Posted 4 years ago #

    try replacing the plus sign with a minus :)

  6. Tosh
    Member
    Posted 4 years ago #

    global $user_ID;
    if( $user_ID ) {
    	$user_info = get_userdata( $user_ID );
    	// If user_registered date/time is less than 48hrs from now
    	// Message will show for 48hrs after registration
    	if ( strtotime( $user_info->user_registered ) < ( time() - 172800 ) )
    		echo 'Welcome, ' . $user_info->display_name . '. Thanks for registering.';
    }

    Tried it with a minus, no change .. mmmm

  7. blackened
    Member
    Posted 4 years ago #

    Well, I would like to chime in and say I too would love to have a first login redirect to change password and update a few custom fields the first go-around. I am probably looking at creating a custom form page with just the fields I need and making some custom validation to require/not-require certain fields.

    As far as the first login redirect goes, I think the only way to do it would be to store a custom per-user field in the database, like "hasLoggedIn" that is set to false by default. Then a custom action (I assume - I have not really delved into WordPress development-wise very deeply yet) would need to be added to wp-login that would check that variable, and if false, redirect to the special page and set it to true. If the variable is true, it just does nothing.

    That would be my guess, but like I said as far as actual implementation I would have to be a lot further along with my PHP skills and my familiarity with wordpress before I could tackle a full-blown plugin.

    I will post here if I have a chance to make any head-way. Any tips on the subject would be greatly appreciated!

    Thanks
    Scott

  8. Bryce Corkins
    Member
    Posted 4 years ago #

    The minus is correct, but the < should be a >

    I did a neat little JQuery twitter-style dropdown welcome message to users who have just registered... I have a short tutorial on my site if anyone finds it useful:

    http://www.brycecorkins.com/blog/2010/jquery-dropdown-message-on-first-login/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.