• Resolved billw16

    (@billw16)


    Simple Goal: Do not redirect new users to the WP Edit Profile Page on their initial login (using the native WP Registration process).

    I do not want to permanently redirect users to some other page (that would defeat any bookmarks, links, and any other navigation to a restricted page). I do not want to prevent users from EVER going to their Edit Profile Page, I just don’t want them to AUTOMATICALLY go there when they first login.

    Should be simple right? Honestly I think this should be a setting in WP core – I mean really, who wants their new users to immediately go to their profile edit page? Anyway, in fact the solution is very simple, but (maybe because I’m new to WP and php) this took me a lot of time – searching for a plugin, or code, and trying various things that didn’t really work for us. Since I didn’t find a plugin, nor a post about how to do this, I thought I’d post my solution. Hopefully this will help others.

    I added the code below to our site plugin. (for site plugin see https://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/ ):

    /* REDIRECT AFTER INITIAL LOGIN
    * Prevents new users from automatically going to profile page
    */
    function my_login_redirect( $redirect_to, $request, $user ) {
    $admin_url = home_url().”/wp-admin/”;
    if ( $redirect_to == $admin_url ) {
    if (empty($request)) {
    return home_url();
    } else {
    return $redirect_to;
    }
    } else {
    return $redirect_to;
    }
    }
    add_filter( ‘login_redirect’, ‘my_login_redirect’, 10, 3 );

    Obviously, you could redirect to any other page rather than home_url, or add other conditions as needed. If anyone has improvements on this, they are welcome.

    NOTE: This solution is dependent on the way the native WP registration process currently works, which may change in some future update. Currently (WP 4.5.2) after the user confirms or changes their password (by following a link in the registration email they received), they are prompted to login, after which they are automatically redirected to WP administration (home path \wp-admin\) which calls profile.php and ‘$request’ is empty.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You’re a stud! Thanks! This is something that I’ve struggled to find a good solution to for over a year now. I’ve tried Theme My Login and Peter’s Login Redirect, but neither solved the issue for me (and I prefer not to use plugins if I don’t have to). But I could never get any of the code-based solutions to work either. But yours was as easy as copy/paste into my functions.php file. Thanks!!!

    Thread Starter billw16

    (@billw16)

    Thanks, very glad this helped!

    Hello,
    Do not Redirect new user to Edit Profile Page.
    Here is the access link for verification:

    https://www.togodeep.com.br/

    NOTE: Login does not occur and no error message

    The objective is to direct the new user to a restricted area to view and edit personal data, requests, etc …

    Thread Starter billw16

    (@billw16)

    Sorry but not sure what your point is, do you have a question?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Do Not Redirect new user to Edit Profile Page’ is closed to new replies.