WPFront
  • Home
  • Plugins
    • Notification Bar Plugin
      • Plugin Ideas
      • Plugin Settings
      • Plugin FAQ
    • Scroll Top Plugin
      • Plugin Settings
      • Plugin FAQ
    • User Role Editor Plugin
      • Plugin Documentation
      • Plugin Settings
      • Plugin FAQ
    • Paddle Gateway Plugin
  • Go Pro
  • Support
    • Documentation
    • FAQ
  • Affiliates
  • Contact
  • Login
  • Cart

Tagged: login, redirect

  • This topic has 27 replies, 2 voices, and was last updated 9 years, 8 months ago by Syam Mohan.
Viewing 13 posts - 16 through 28 (of 28 total)
← 1 2
  • Author
    Posts
  • August 11, 2015 at 3:08 am #14191
    Bratt
    Participant

    I diden’t get it to work, does it work for you ?

    August 11, 2015 at 9:27 am #14228
    Syam Mohan
    Keymaster

    Can you also check your PHP opcache revalidation setting?

    August 11, 2015 at 11:20 pm #14250
    Bratt
    Participant

    Do you have any tips for where i can find the setting except contact my hosting company?.

    August 12, 2015 at 6:56 am #14277
    Syam Mohan
    Keymaster

    Are you hosting on a shared server or VPS?

    I’ll give it another try since you disabled Wordfence.

    Thanks

    August 12, 2015 at 1:36 pm #14309
    Bratt
    Participant

    It’s a shared server.

    August 12, 2015 at 6:33 pm #14318
    Syam Mohan
    Keymaster

    Hi Bratt,

    It seems like the caching is still there. I’ll try to do the code on one of my development sites and send it you. It will take me sometime, since I need to setup the testing environment.

    Thanks

    Syam

    August 13, 2015 at 3:08 am #14338
    Bratt
    Participant

    Much appreciated ! =)

    August 15, 2015 at 5:49 pm #14462
    Syam Mohan
    Keymaster

    Hi Bratt,

    The reason it was not working because its too late to redirect from a page template.

    function login_page_template_redirect() {
        if(is_page('login')) {
            if(is_user_logged_in()) {
                wp_redirect(apply_filters('login_redirect', '/'));
            } else {
                wp_redirect('/wp-login.php');
            }
            exit();
        }
    }
    add_action( 'template_redirect', 'login_page_template_redirect' );
    

    Try putting the above code within the functions.php.

    Thanks

    Syam

    August 19, 2015 at 11:12 pm #14773
    Syam Mohan
    Keymaster

    Hi Bratt,

    Does the code work?

    Thanks

    Syam

    August 20, 2015 at 11:53 pm #14887
    Bratt
    Participant

    Hi!

    Sorry, i had totally missed your answer =)

    Tried it this morning and it works great as it seams. It gives error if the user’s role has no redirect role.
    ERR_TOO_MANY_REDIRECTS
    Like admin account but that is something that is acceptable.

    Your the hero of the year!! Wow, thanks for the exceptionally grate support.

    August 21, 2015 at 4:59 am #14905
    Syam Mohan
    Keymaster

    Hi Bratt,

    The reason you are getting that error is, that code specifies the home page(‘/’) as the default redirect location if no login redirects found for that user. But your home page also uses this template. So it goes into a redirect loop. You will have the same error, if the URL configured within the login redirect uses the same template/code.

    To fix the error, change the default location to a URL which do not use this template/code. For example, change it to ‘/abc/’ and make sure page ABC do not use this template/code.

    So your code will change like this.

    wp_redirect(apply_filters('login_redirect', '/abc/'));
    

    Let me know if it doesn’t work.

    Thanks

    Syam

    August 24, 2015 at 2:22 am #14985
    Bratt
    Participant

    Works like a charm 🙂

    August 24, 2015 at 8:42 am #14998
    Syam Mohan
    Keymaster

    Glad to help.

    Thanks

  • Author
    Posts
Viewing 13 posts - 16 through 28 (of 28 total)
← 1 2
  • The topic ‘If logged in redirect to Login Redirect url?’ is closed to new replies.
Log In
Lost Password

Search Topics

Documentation

FAQ
Roles List Add Role Edit Role Delete Role Restore Role Add or Remove Capability Assign/Migrate Users Posts/Pages Extended Permissions Custom Post Type Permissions Navigation Menu Permissions Widget Permissions Admin Menu Editor Media/Attachment File Permissions User Level Permissions Content Restriction Shortcodes Login Redirect Export Roles Import Roles Bulk Edit Settings Multisite Roles List Multisite Add New Role Multisite Edit Role Multisite Delete Role Multisite Restore Role Multisite Sync Roles Multisite Settings WordPress Capabilities Actions and Filters Installation Instructions