• Resolved aojohnson

    (@aojohnson)


    Hello,

    I’m having an issue since the last update to version 2.8.4

    We’re using the following in functions.php to redirect all users to the /login-register page where we use the profile builder login. This is so that users, unless admin, cannot access wp-login.php or wp-admin URLs

    add_filter('login_url', 'your_login_url', 10, 2 );
    add_action('login_init', 'your_login_page');
    add_action('wp_login', 'your_login_redirect', 10, 2);
    //
    // assuming that your new front end login url is "/login-register", use this:
    function your_login_url($login_url, $redirect) {
        return home_url('/login-register');
    }
    
    function your_login_page() {
        wp_redirect(home_url('/login-register'), 302);
    }
    
    // if admin send them to the dashboard, otherwise leave them on the frontend
    function your_login_redirect($user_login, $user) {
    
        if  (current_user_can('activate_plugins')) {
                wp_redirect('/wp-admin/index.php', 302);
    		}
        else {
            $url = home_url('/login-register/');
            }
    	}
        return; 

    Worked great, until update. After update, even admins cannot access any wp-admin pages, we’re simply getting redirected back to /login-register???
    If I comment out add_action('login_init', 'your_login_page'); I can access the admin area, but then it actually seems to direct to wp-login.php after logging in through profile builder.

    On our site, I’ve rolled back profile builder to version 2.8.3 so that it continues to work as I would like. I’m just wondering what the reason is for this, and how I can update without having this issue.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Georgian Cocora

    (@raster02)

    Hello @aojohnson,

    We did some refactoring to the Login form with the latest update.

    Can you change your code to this and give it a try, it should work:

    add_filter('login_url', 'your_login_url', 10, 2 );
    add_action('login_init', 'your_login_page');
    add_action('wp_login', 'your_login_redirect', 10, 2);
    
    // assuming that your new front end login url is "/login-register", use this:
    function your_login_url($login_url, $redirect) {
        return home_url('/login-register');
    }
    
    function your_login_page() {
        global $pagenow;
        
        if ($pagenow == 'wp-login.php')
            wp_redirect(home_url('/login-register'), 302);
    }
    
    // if admin send them to the dashboard, otherwise leave them on the frontend
    function your_login_redirect($user_login, $user) {
    
        if  (current_user_can('activate_plugins')) {
                wp_redirect('/wp-admin/index.php', 302);
    		}
        else {
            $url = home_url('/login-register/');
            }
    }
    

    Let me know.

    Regards.

    Thread Starter aojohnson

    (@aojohnson)

    I’m getting a fatal error so the changes will not save…?

    Plugin Author Georgian Cocora

    (@raster02)

    Hello,

    Can you show the error to me ? I can save the code without issues.

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Login Redirect Structure Issue’ is closed to new replies.