Title: Login Redirect Structure Issue
Last modified: June 5, 2018

---

# Login Redirect Structure Issue

 *  Resolved [aojohnson](https://wordpress.org/support/users/aojohnson/)
 * (@aojohnson)
 * [8 years ago](https://wordpress.org/support/topic/login-redirect-structure-issue/)
 * 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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Flogin-redirect-structure-issue%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Georgian Cocora](https://wordpress.org/support/users/raster02/)
 * (@raster02)
 * [8 years ago](https://wordpress.org/support/topic/login-redirect-structure-issue/#post-10373198)
 * Hello [@aojohnson](https://wordpress.org/support/users/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](https://wordpress.org/support/users/aojohnson/)
 * (@aojohnson)
 * [8 years ago](https://wordpress.org/support/topic/login-redirect-structure-issue/#post-10375223)
 * I’m getting a fatal error so the changes will not save…?
 *  Plugin Author [Georgian Cocora](https://wordpress.org/support/users/raster02/)
 * (@raster02)
 * [8 years ago](https://wordpress.org/support/topic/login-redirect-structure-issue/#post-10378346)
 * 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.

 * ![](https://ps.w.org/profile-builder/assets/icon-256x256.png?rev=2961144)
 * [User Profile Builder - Beautiful User Registration Forms, User Profiles & User Role Editor](https://wordpress.org/plugins/profile-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/profile-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/profile-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/profile-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/profile-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/profile-builder/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Georgian Cocora](https://wordpress.org/support/users/raster02/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/login-redirect-structure-issue/#post-10378346)
 * Status: resolved