Arrow

Redirect WordPress users to different locations after they log in

First published on September 8, 2008

With the release of WordPress 2.6.2 came a new filter for the “redirect to” address. For the non-technical folk, this means that you can specify different landing pages for different users after they log in. For example, you might have built a custom page for editors with custom news, edit links, and other special information. You can thus redirect them to that URL instead of the default WordPress dashboard.

I started to work on using such a feature previously but WordPress 2.6.2 makes the functionality a lot cleaner. Therefore, I’ve built a plugin that lets you redirect users based on their usernames, roles, and levels and capabilities (in that order).

Once you’ve uploaded and enabled the plugin, you use a management page under Settings > Login/logout redirects to manage the redirect rules:

Peter's Login Redirect

In addition to the user-, role-, and level-based rules, you can also define a “catch-all” redirect URL for all other users for which the rules don’t match. You can also define a post-registration redirect URL. Note that WordPress does not allow you to redirect to external sites by default. (In other words, if your site is yoursite.com, you can redirect to yoursite.com/custom_page.php but not to theblog.ca.) Starting in version 1.7.0 of the plugin, there is a setting $rul_local_only in the plugin file itself that will disable this limitation (and does so by default). To add domains to the “allowed redirect” list in WordPress, use a plugin similar to this.

There is also a feature to configure a custom logout URL.

  • Need functionality to redirect users on first login? See the documentation in “How to Extend” in the readme.txt file, or use the standalone functionality.
  • Need functionality to redirect users based on an IP address, or based on custom login? See the documentation in “How to Extend” in the readme.txt file for examples on how to extend the plugin.
  • Need functionality to redirect users back to the same page where they logged in from? See this comment for ideas.

Download Peter’s Login Redirect Version 2.9.2 (Make sure you have WordPress 3.2.0 or higher!)

  • nl_NL translation by Anja
  • sk_SK translation by Michal Miksik
  • ro_RO translation by Anunturi Jibo of http://www.jibo.ro
  • cs_CZ translation by Petr Mašek and Michal Kuk
  • de_DE translation by Lara and Mario
  • es_ES translation by Closemarketing
  • lt_LT translation by Vincent G
  • da_DK translation by Tom
  • id_ID translation by Syamsul Alam
  • uk translation by Yura
  • sr_RS translation by Borisa Djuraskovic
  • fr_FR translation by DomBonj
  • pt_BR translation by Graal4
  • ru_RU translation by Sergey

Troubleshooting
Login redirects not working? This plugin uses WordPress’s standard login_redirect hook. The usual cause of problems is that another plugin is using the hook first, or there is a custom login form that isn’t even running through the standard WordPress login functions.

These threads might be useful:

Also see the instructions at the bottom of the settings on the “Settings > Login/logout redirects” page in the WordPress admin panel that says:

“Use external redirect file. Set this to “Yes” if you are using a plugin such as Gigya that bypasses the regular WordPress redirect process (and allows only one fixed redirect URL). Then, set the redirect URL in the other plugin to
http://www.yoursite.com/wp-content/plugins/peters-login-redirect/wplogin_redirect_control.php”

Version history
2.9.2: Add CSRF protection (thanks RIPS!). Fixed translations for “username” variable instruction (thanks Jaime!).
2.9.1: Support utf8mb4 encoding and prevent cross-site scripting when editing redirect URLs.
2.9.0: Update translation text domain in order to support translate.wordpress.org translation system.
2.8.3: Add new URL variable “userslug” to match author URLs.
2.8.2: Translation string fix.
2.8.1: Support the deletion of rules referencing deleted user, roles, or levels.
2.8.0: Improved management interface to add specific Edit and Delete buttons per rule, and removed limit around number of rules.
2.7.2: Support PHP 5 static function calls, bumping WordPress requirement to 3.2+.
2.7.1: Bug fix: Role-based login URLs weren’t saving correctly.
2.7.0: Add logout redirect URL control per-user, per-role, and per-level.
2.6.1: Allow editors to manage redirects in WordPress 3.5+ (required capability is now “manage_categories” instead of “manage_links”).
2.6.0: Added support for URL variable “http_referer” (note the single “r”) to redirect the user back to the page that hosted the login form, as long as the login page isn’t the standard wp-login.php. There are several caveats to this, such as: If you want to redirect only on certain forms and/or specify a redirect on the standard wp-login.php page, you should modify the form itself to use a “redirect_to” form variable instead.
2.5.3: Bug fix: Fallback redirect rule wouldn’t update properly if logout URL was blank on MySQL installs with strict mode enabled (thanks kvandekrol!)
2.5.2: Bug fix: Fallback redirect rule updates were broken for non-English installs.
2.5.1: Bug fix: Redirect after registration back-end code was missed in 2.5.0, and thus that feature wasn’t actually working.
2.5.0: Added redirect after registration option. Also made plugin settings editable in the WordPress admin panel.
2.4.0: Added support for URL variable “postid-23″. Also added documentation on how to set up redirect on first login.
2.3.0: Added support for URL variable “siteurl” and “homeurl”. Also added filter to support custom replacement variables in the URL. See readme.txt for documentation.
2.2.0: Support basic custom logout redirect URL for all users only. Future versions will have the same framework for logout redirects as for login redirects.
2.1.1: Minor code cleanup. Note: users now need “manage_links” permissions to edit redirect settings by default.
2.1.0: Added hooks to facilitate adding your own extensions to the plugin. See readme.txt for documentation.
2.0.0: Added option to allow a redirect_to POST or GET variable to take precedence over this plugin’s rules.
1.9.3: Made plugin translatable (Thanks Anja!)
1.9.2: Bug fix in code syntax.
1.9.1: Bug fix for putting the username in the redirect URL.
1.9.0: Added support for a separate redirect controller URL for compatibility with Gigya and similar plugins that bypass the regular WordPress login redirect mechanism. See the $rul_use_redirect_controller setting within this plugin.
1.8.1: Added proper encoding of username in the redirect URL if the username has spaces.
1.8.0: Added the ability to specify a username in the redirect URL for more dynamic URL generation.
1.7.3: Minor tweak on settings page for better compatibility with different WordPress URL setups.
1.7.2: Plugin now removes its database tables when it is uninstalled, instead of when it is deactivated. This prevents the redirect rules from being deleted when upgrading WordPress automatically.
1.7.1: Minor database compatibility tweak. (Thanks KCP!)
1.7.0: Added option $rul_local_only (in the plugin file itself) to bypass the WordPress default limitation of only redirecting to local URLs.
1.6.1: Minor database table tweak for better compatibility with different setups. (Thanks David!)
1.6.0: Added a function rul_register that acts the same as the wp_register function you see in templates, except that it will return the custom defined admin address.
1.5.1: Fixed compatibility for sites with a different table prefix setting in wp-config.php. (Thanks Eric!)
1.5: GUI for WordPress 2.6.2 and higher

Troubleshooting

  • If the MySQL user on your WordPress blog doesn’t have the necessary CREATE TABLE privileges to install the plugin, you can look in the plugin file for the CREATE TABLE SQL code and manually insert it into the database using something like phpMyAdmin (ask your web host about that if you’re not sure what that means.
Forum/Topic Started Last post Posts

Peter’s Login Redirect

****ERROR: Unknown error adding user-specific redirect for user ****

October 24, 2014
11:45 am by
chronicle
View

October 27, 2014
7:49 am by
Peter
View

4

Peter’s Login Redirect

Logout works great, but log in keeps going to my account page

May 19, 2014
6:19 pm by
GreenPeakLabs
View

August 26, 2014
4:47 pm by
Peter
View

5

Peter’s Login Redirect

Login Redirect Users Registered Before X Date

August 12, 2014
8:45 am by
fcvolunteer
View

August 15, 2014
12:34 pm by
fcvolunteer
View

6

Peter’s Login Redirect

****ERROR: Unknown database problem updating URL for “all other users” ****

July 30, 2014
6:34 pm by
Desktop Masters
View

August 3, 2014
11:44 am by
Peter
View

2

Peter’s Login Redirect

Removing Users

May 19, 2014
8:17 pm by
tsauer
View

August 3, 2014
11:12 am by
Peter
View

14
Arrow

138 Responses to “Redirect WordPress users to different locations after they log in”


  1. John says:

    Awesome… we have a half-dozen authors, and a few get freaked out by the WordPress core. I can’t wait to try this… THANKS!


  2. Lynette Chandler says:

    Fabulous. Thank you Peter. I have been using an older plugin that is no longer supported but this is even better. Love the specific level option if it does what I think it does :) Just uploaded this, still finding way around.


  3. Richard Tapr says:

    Hi, is there a version of this plugin which works for versions prior to 2.6.2 … I have 2.6 (and seeing as 2.6.1 and 2.6.2 aren’t required updates, I haven’t made the transition on my sites yet (it’s not a small job, sadly) … thanks very much in advance


  4. Peter says:

    Hi, you can try this one:

    http://www.theblog.ca/wplogin-front-page#comment-9684

    It has almost the same intended functionality as version 1.5 of the plugin but it has no GUI management. So to modify settings you have to edit the section near the top of the plugin file itself. The difference in its functionality is in how it sets the redirect variable — it might not work on all installs but it’s probably worth a try.


  5. Eric says:

    Thanks for spending your time to create this plugin, it is just what I was looking for. I ran into one small problem though once the plugin was installed and activated on WP 2.6.2.

    I think line 65 assumes that the WP tables use the WP_ prefix:

    if ( isset ( $user->wp_capabilities[$rul_role->rul_value] ) ) {

    I have something other than WP_ as my prefix and so no user role rules were working correctly. I am not that great with php but could you add "$wpdb->prefix" to cover any prefix?

    Thanks


  6. Peter says:

    Hi Eric, you’re right. I had no idea that WordPress variables were also affected by the prefix. In that case you can use $wpdb->prefix. I’ll have to investigate further to see how far-reaching the prefix goes.

    Update: Version 1.5.1 released to addressed this issue


  7. Esther says:

    Thank you Peter … such a useful plugin. Thanks for this!


  8. Brian says:

    Will the 1.5.1 version of the plug-in likely to work with WPMU 2.6.2?

    It doesn’t seem to work with our current WPMU version 2.6 and I suspect that I either need to use an earlier version or else upgrade to WPMU 2.6.2, which came out a couple of days ago.

    Thanks


  9. ccmedia365 says:

    I want to use this plugin with Themed Login, but they don’t seem to be compatible together. Can you tell how to make them work together? I’m at a loss. Thanks!


  10. Peter says:

    @Brian: unfortunately, it won’t work with WPMU 2.6.2. For some reason the MU version of 2.6.2 does not use the same new login_redirect hook that the normal WordPress 2.6.2 version implemented. You can use the older version of my plugin, but then all redirect rules would be global for all blogs. I would consider making an MU-compatible version of the plugin after that login_redirect hook is added to the core code.


  11. Peter says:

    @ccmedia365: From what I can see, the Themed Login plugin completely replaces the native wp-login.php file and it is starting to get out of date. There wouldn’t actually be any incompatibility if that plugin used the core hooks that WordPress has implemented over the past year. Your best bet is to ask for an update to the Themed Login plugin.


  12. Ruiz says:

    Awesome plugin, it’s just what I needed!

    Forgive me for asking, but is there anything I can type to redirect the user to the previous page they were on?


  13. Peter says:

    Hi Ruiz,

    No, that’s not a built in feature. However, I might incorporate that into a future release. Are you making a custom login form on a page other than wp-login.php? If I were to incorporate that feature, I would probably make it so that users could be redirected back to where they came from, but only if they did not log in through wp-login.php.


  14. Ruiz says:

    Yeah, I have my users login through wp-login.php. It’s cool, I was just curious as to if it were possible.

    Again, thanks for the awesome plugin!


  15. Peter says:

    In that case, what you want to do is possible without a plugin. Just link to the wp-login.php file like so:

    http://yoursite.com/wp-login.php?redirect_to=http://yoursite.com/whereyouwanttoredirect


  16. Alison says:

    Your plugin does everything I want it to do! In the past I’ve been editing core files for things to re-direct, but with this, it’s obviously much better. However, for some strange reason, your plugin isn’t showing up in the plugin list! I’m using version 2.6.2 of WP and I’ve tried both putting the folder and just the file in the plugin directory. I’m pretty stumped, this has never happened before! Any ideas?


  17. Peter says:

    Hi Alison, I am also stumped. Maybe it’s the permissions on the file or perhaps it’s actually listed, but not that WordPress splits the lists into "Active", "Recently active", and "Inactive" lists, it’s way down in the list of inactive plugins? I know, that’s a stretch, but it’s all I can think of without actually seeing your install.


  18. Alison says:

    Thanks Peter, but I’m not sure what it is. Whatever it might be, it definately doesn’t have anything to do with your script in particular, it’s everyone’s! My plugin list isn’t updating, so I posted a support post on the wordpress forums, hoping for some answers. This is so bizarre!


  19. gaurav says:

    When I select a role and put in the URL for the dashboard and click Submit, it returns to the same page but does not show the Role and Redirect is had set.
    Same for user or Level etc.
    Basically clicking on Submit makes the page redirect but nothing gets set.
    Using WP 2.6.2 on Windows server

    Update: gaurav had an issue with the server configuration and hosting multiple domains. As a result, the form was posting to a different location. To solve the problem, he hard-coded his site URL into the form URLs.


  20. Espen says:

    Hi,

    Elegant solution to something most admins and users want I assume.

    Whenever you have the time, maybe do the same thing for log out events as well :)


  21. Don says:

    Peter,

    It looks like your plug-in will do what I need (re-direct people logging in to the home page). I set the users to ‘contributors’ already, so when I use your plug in it’s a simple matter of picking "Roles" and then putting in the URL. The only problem is that the URL is repeated, thus giving me an error. And I can’t leave it blank. So when I log-in, the URL bar now tells me (as an example) http://www.squidmonkey.com/www.squidmonkey.com

    Thoughts?


  22. Peter says:

    Hi Don, this might be a long shot, but did you forget to enter the "http://" as part of the address?


  23. Don says:

    I tried. If I put in the ‘http://’ it gives me an error saying "****ERROR: Non-local or invalid URL submitted for role "contributor"****

    and when I just put in "www.squidmonkey.com" it doesn’t give me an error, but when I log in, it puts "http://www.squidmonkey.com/www.squidmonkey.com" in the URL bar.


  24. Peter says:

    Is your blog address one level up (like /blog or /wordpress)? By default, WordPress doesn’t let you redirect to a URL outside of your blog. For future releases of this plugin, I’ll look into adding the ability to add URLs to the WordPress "allow redirect" list. If you’re technically inclined you can also look this up in the meantime.

    Update: To add domains to the “allowed redirect” list in WordPress, use a plugin similar to this.


  25. Don says:

    Nope, WP is installed on the top level, no backslashes required.


  26. Peter says:

    Solution in Don’s case: the blog address was configured as something like "squidmonkey.com", so WordPress wasn’t allowing "www.squidmonkey.com" as the redirect URL. When he entered "http://squidmonkey.com" it worked.


  27. André Loibl says:

    Hi Peter,

    what a wonderful plugin – thank you!! :-))
    I use it on a membership wp site – it looks strange to users when they are directed to their profile… so your plugin is just perfect!!!

    THANK YOU!!! :-))

    André


  28. Mike says:

    Great Plugin!
    Can you incluse redirect option for logout also..

    Can i use this for my site with wordpress 2.5.1 ..

    Is it compactible with wordpress 2.5.1 ..


  29. Peter says:

    Hi Mike, this plugin requires WordPress 2.6.2 and higher. The previous incarnation of this plugin is compatible with 2.5.1:

    http://www.theblog.ca/wplogin-front-page#comment-9684

    As for the "redirect on logout" option — this is possible but would require tweaking a core WordPress file. In other words, that functionality is not suitable for a plugin yet.


  30. gsharp says:

    This is just fantastic plug-in. I noticed one issue though. In my customer facing site, a "Register" link exist for registration function which display when the user is logged-out.
    When the user logs in, this switches to "Site Admin" and redirects to the Dashboard upon when clicked.

    Any idea how to fix this?


  31. Peter says:

    Hi gsharp, that comes from the wp_register function that is called in your template. You can remove it altogether or, if you really want a user-specific "Site Admin" link, it would take some coding to do the trick (maybe a future feature addition for this plugin).

    Update: Version 1.6.0 of this plugin adds the capability for a user-specific Site Admin link


  32. gsharp says:

    Thanks so much for the upgrade Peter…I downloaded the new version but it doesnt look like its working for me. My SiteAdmin is still going to the dashboard. Is that the expected result? I dont see any extra or new configuration setting in Login Redirect page to emphasize configuration for Site Admin or am I missing it?
    I even deactivated, removed and reinstalled the plugin but still did not see any changes.
    Please help…


  33. Peter says:

    Hi gsharp, you need to replace the call to wp_register() in your sidebar template to rul_register(). There’s a brief explanation of this in the readme.txt file or on the wordpress.org plugin page.


  34. gsharp says:

    Fantastic! That worked! I am sure you heard this before but I did (honestly I did) read the readme.txt file but didnt sink in that I have to modify the sidebar.php.
    This is awesome! Hats off to you :).. Thanks so much.


  35. max supera says:

    any way to make it redirect to what ever page the user logged in from?


  36. Peter says:

    Hi max,

    There isn’t a specific setting for that. However, if there’s only one point of entry, you can just create a global redirect rule for all users. Or, you can make each form post to http://yoursite.com/wp-login.php?redirect_to=http://yoursite.com/whereyouwanttoredirect


  37. Souvik says:

    Thanks for the plugin. I have been trying to create a website using WPMU where all blog users have to log in before they can be shown their blog or landing page. Since I am not a php programmer or a wordpress expert by any measure, this plugin just saved me a lot of time.


  38. GermanJoe says:

    works fine, love it!
    good work!


  39. Ron says:

    Installed the plugin and it works as described.

    I also have the sidebar login plugin installed and was wondering if there is a way to return to the calling page.

    The sidebar login returns to the calling page on login but if you click on the register or lost password links it takes you to the standard WP login page.

    When you complete the entries for registration, your plugin will redirect to the home page (my setting for subscribers) instead of the dashboard.

    Ideally I would like to have the user returned to the calling page (which may be one of several pages that the sidebar login is displayed on).

    Is this possible with your redirect plugin?

    Thanks


  40. Peter says:

    Hi Ron,

    Short of hacking the registration page, I don’t know of a way to carry a "redirect_to" address for the registration workflow. As for the case where you are just redirecting to the referring page on normal logins, you can just make your custom login forms include a hidden POST variable "redirect_to" with the address of the page people are on.


  41. Jørgen says:

    Thank you Peter. You saved me for several days work!


  42. Ron says:

    thanks peter I’ll try your suggestion.


  43. Kitty Bradshaw says:

    Hi, before I download this I am curious to know if this plugin will help my specific situation.

    Basically I am wanting to add a "page" on the top bar next to the home and about me pages. However, I really want this page to take readers to my social network (I guess redirect). I want this to work for all readers not just people logged in.

    Will this plug-in work for what I am trying to do?

    Reply from Peter: You don’t need a plugin for that. To create a direct link on your menu, you just need to add the link within one of your theme’s files (the exact file and location would depend on your theme).


  44. Kitty Bradshaw says:

    Thank you sugar! :)


  45. Andy says:

    Hi Peter,
    This plugin is exactly what I’m looking for. However, I’ve installed and adjusted the settings and it’s not redirecting. Specifically, I set it up so that all subscribers go to a specific link. Then I tested it as a subscriber using a different browser altogether (that I haven’t used to access the blog before, so there are no caching issues). Unfortunately, after logging in, I went to the admin page and not the desired redirect.

    Any thoughts on what I’m doing wrong?

    Thx,
    a


  46. Andy says:

    Oh geez, this specific installation of WP is 2.6. Sorry about that! Will try on 2.6.2 or higher shortly.

    Looking forward to it!


  47. Luanigio says:

    Thank Peter!
    That is what I need. Happy New Year, Ciao!


  48. Claire says:

    I notice that the ‘Site Admin’ link has changed to ‘My Profile’, but I can’t see where to change the text or destination for this link – can anyone help?


  49. Peter says:

    Hi Claire, that sounds like something another plugin might have done. In my plugin, the words "Site Admin" are hard-coded in the rul_register function (you can certainly change that).


  50. mike says:

    Open source communities can certainly be a great thing! Thank you Peter for making something so useful and so free! Thanks to people like you, website development doesn’t have to be the sole province of the code savvy and the deep-pocketed! Keep up the good work!


  51. Benjamin Allison says:

    This is perfect! One question:

    Is it possible to have this plugin automatically redirect the user to a page of the same name?

    Exampe: say I create a user (specifically a subscriber) who’s name is "john_smith." Can the plugin be tweaked to catch this, and have him automatically go to a page I create by the same "www.mysite.com/wp/john_smith," instead of me having to tick off the settings for him?

    Thanks!


  52. Peter says:

    Hi Benjamin, that is certainly possible under the framework, but that would be custom development that wouldn’t follow the main release of the plugin. In the redirect_to_front_page() function in the plugin, you can write your own logic using $user->user_login to return the appropriate $redirect_to value.


  53. Benjamin Allison says:

    Thanks for the amazingly fast response!

    I’ll poke around. Thanks for all your hard work Peter!


  54. Yongho Kim says:

    Hey,

    this is my trick for making people go back to where they came from after the login:

    1. Redirect to X page.
    2. On X page, load up a javascript forcing the user to go back 2 pages (1 for the login page, and 2 for the original page)

    My implementation was setting up a wiki page with securehtml enabled: http://krcla.org/blog/w-en/index.php?title=Gobacktwo&action=edit

    Let’s see if the code pastes properly here:
    <html><script type="text/javascript">
    function redirectIt() {
    window.location.replace(history.go(-2));
    }

    window.onload = redirectIt;
    </script></html>


  55. Benjamin Allison says:

    Hey, just one more question:

    What would it take to redirect the user if they key in the wp-admin URL into their browser?

    Thanks again!


  56. Benjamin Allison says:

    Sorry! Scratch the last question. What I really want to know is, can I set it up so that when I create a user, values for <i>rul_username</i> and <i>rul_usernameaddress</i> will be sent automatically?


  57. mbrooklyn says:

    I know this isnt quite the right spot to ask this, so, apologies. i am new at wordpress, and trying to figure out if i have to use the wp-login in the sidebar, or if i can get the login into the masthead area somehow?
    thanks–


  58. Peter says:

    Benjamin: There’s a nice outline on how to block wp-admin in this plugin. Also, you can certainly trigger the creation of relevant database rows if you reference WordPress’s user creation hook: user_register or something similar.

    mbrooklyn: You can display or move the login link or form to anywhere you want — it’s just a matter of editing the templates. Place <?php wp_loginout(); ?> wherever you want in your templates for the appropriate link(s) to be displayed. For an example on display the form, see here.

    Generally, for unrelated WordPress questions I suggest using the support forum, as you’ll get more people than just me:

    http://wordpress.org/support/


  59. mbrooklyn says:

    thanks! i ended up moving the wp-login.php into my masthead, and it seems to be working. i appreciate your help!


  60. ron says:

    is there a way to return to the page the user clicked on to register or login in the sidebar.

    I would like the user to be able to return to the calling page.

    Is this possible with this plugin?

    thanks


  61. Peter says:

    Hi ron, please see this comment.


  62. ron says:

    Peter,

    I just looked again at your suggestion and am not sure it will do what I want.

    The login and register links in the sidebar are the same on every page.

    I want the users to return to the calling page.

    The code you suggest

    http://yoursite.com/wp-login.php?redirect_to=http://yoursite.com/whereyouwanttoredirect

    would return them to only one page, wouldn’t it? unless there is a way to pick up the page id and insert it in the sidebar code when a user clicks on login or register. I am not sure how that would be done.


  63. Peter says:

    Yes, you can use PHP functions to print out the current URL. This would only work for logging in — I don’t know of a graceful solution for redirecting to a variable page after registering.


  64. Drew says:

    This saves me a lot of time, having had to manually redirect in the past. I was just wondering, could it be modified so that it not only worked at login, but if subscribers tried to visit certain categories then it would redirect them away?
    I would have a go at this myself but my php skills are no way near good enough!
    Failing that, would you be able to point out to me the code that you use to detect which role the user has.
    Thanks in advance

    Reply from Peter: The plugin is certainly adaptable for category redirection, but it would be quite a bit more work than just flicking a switch. Getting the current user’s role is a bit complicated and you could also try using levels. Read this and this and also explore the $current_user object. Without getting into too much detail, if you look at the user object, you’ll get an array with the current user’s roles:

    global $current_user;
    print_r($current_user->data->wp_capabilities);


  65. Giuseppe says:

    Thank you so much! I had a problem to implement a registered user chat and your plugin let me redirect users that register for the event directly to the chat page.


  66. Drew says:

    Thanks for getting back to me dude. I ended up using the capabilities to decide:
    current_user_can(‘edit_posts’)
    Simple, just like me! Thanks again though.


  67. Scott-TheBrewClub says:

    OK – I’m not a coder, so bare with me! I think this plugin is really close to hat I need. I need people to be redirected to different URLs based on the login. Will this work for that, or will it only redirect within the WP site itself?

    Lets say user A logs in on mysite.com, can he be directed to demosite1.com, while user B would be directed to demosite2.com?

    Is this what you were talking about with the ‘allow redirect’ list?

    If this is nonsensical, I’m a little bleary eyed trying to find a solution for this! TNX!


  68. Scott-TheBrewClub says:

    Useful crap? I would say so! I edited and added your redirect hosts file as a plugin, along with the redirect plugin, and I can now redirect based on user names to outside URLs! THANK YOU!!!!


  69. Gayan says:

    Hey Peter,

    I’m using your pluggin now and its a woderful one. I have one question tho.
    The reply you’ve given to the comment 10564, i’m still unclear how to use it. I’m not a php guru but i can understand things after looking into them.

    is there a possibility of using `$_SERVER['HTTP_REFERER']` to get the refering URL. or any other method. Please provide a working example as i can’t understand the example you’ve posted.
    Also i looked at the search query but all of them are custom made functions.

    Sorry for troubling you on this.


  70. Peter says:

    If you look in wp-login.php, there is a hook "do_action(‘login_form’)". So you could insert anything into the login form, such as a hidden field with a value of $_SERVER['HTTP_REFERER']. See here for an outline.

    This is far from a perfect solution, since the $_SERVER['HTTP_REFERER'] value could be anything, so you should definitely add to those examples and do some validation. You also need to decide what kind of priority that is given against any other redirect rules you might have. Also, depending on your needs, you could just put your own mini-login form somewhere else on your site and include a redirect_to field that has a value of the current URL.


  71. Lifeischoice says:

    Peter, I am not a coder!…and I have a plugin based on account types and would like to redirect based on these types….the types can be accessed with a call to a function: user_accout_types() that will display these types….how can I add this check to your plugin to allow redirect based on the account types? Thanks for a great plugin..

    Reply from Peter: All of the main redirect logic in my plugin is in the redirect_to_front_page() function in the plugin file. You could add logic near the top of that function to redirect to different pages based on what is returned by that user_account_types() function in the other plugin. Tighter integration would take at least a couple of hours of work.


  72. Lifeischoice says:

    Please email me with a quote if you can help…Thanks…

    Update from Peter: problem solved :)


  73. HighTechDad says:

    Quick question. We are setting up a mirrored environment (1 Load balancer and 2 WP mirrored servers and 1 backend DB server). We have set one web server as the Master and one as the Secondary. Any changes made within the Master (e.g., files uploaded) the files are either added, changed or deleted from the Secondary. The problem is, we want to make sure that all blog posts/image uploads are done on the Master server only.

    Can we use your plugin to direct all authors and above to hit the Master server (e.g., via an IP address)? So, main domain is http://www.blahblahblah.com. When the author or admin logs in, they are directed to http://208.xxx.xxx.xxx/wp-admin (pages) and do all edits there?

    Thanks!
    -HTD

    Reply from Peter: Yes, as long as the session information carries, and you add the IP address to the list of allowed domains in a plugin similar to this. You might be better off hacking wp-login.php on the main domain to post to the master server and also using an .htaccess redirect so that the main domain’s entire wp-admin folder redirects (making it so that no one, or only a specific IP, can access the main domain’s wp-admin folder).


  74. HighTechDad says:

    Peter,

    The "similar to this" plugin…does this exist or are you saying save the code as a plugin (what name?).

    The goal is not to "hack" the system (to allow for upgrades of WP et al).

    Thanks,
    HTD

    Reply from Peter: Yes, you would save that code as your own plugin and can name it anything you want. It just hasn’t been officially released as a plugin.


  75. SoloCon says:

    Peter,

    Thanks for the plugin! This is just what I am needing. I am having a small issue with it.

    I am using WP 2.7.1, when setting up a user named "test" and enter the password, its redirecting me to /wp-login.php?page_id=26. I have told the plug in to redirect the user to "?page_id=26" No matter what I do, its still redirecting them to domain.com/wp-login.php?page_id=26 which just brings them back to the WP login. I have been fighting this for about 9 hours now trying to fix it on me end. Any idea what might cause this?

    Reply from Peter: It will work best if you enter the full URL: “http://domain.com/?page_id=26″


  76. Charlie says:

    Great plugin Peter, extremely useful and simple. Thanks.


  77. Steve says:

    First, great plugin. Secondly, and my apologies if it’s already been addressed above, but is there a way to have the user redirected to their own member page upon logging in?

    Reply from Peter: Whether you mean their standard “edit profile” WordPress page or something custom that is based on their user ID or username, you can certainly do that. See this comment.


  78. Adam W. Warner says:

    Peter, I just had the occasion to look around for a login redirect plugin and I wanted to write to say "thank you" for releasing this, it’s super useful!

    I have it installed on the main blog of a WPMU 2.7 install and it’s working as expected so far. I really like the idea of the poster above of having a redirect to the user’s member page, and your answer of cluing us in on how to modify.

    Thank you!


  79. Kevin says:

    hey peter,

    great plug-in. works like a charm. i love the login redirected preference. would you know a way to eliminate the subscriber’s "control panel" option, so the subscriber would not have access?

    Reply from Peter: Sounds like some sort of access control plugin will do the trick. See this one, this one, or this one (there are probably many others).


  80. Scott says:

    Is it possible to redirect to the page that the user was on when he clicked "login"? For example, if the user is reading an entry and wants to make a comment, I’d like them to be able to click "login", enter their info, and then get redirected back to the entry page so they don’t have to navigate to make a comment. Thanks!

    Reply from Peter: see this comment.


  81. Leah says:

    This plugin is fantastic! If this is considered crap, I can’t imagine what your "good" coding is like. I have been looking for a way to redirect just subscribers to the index page instead of to their profile dashboard, without affecting the admin login. And this plugin does that perfectly.


  82. Todd says:

    AWESOME, exactly what i needed!!!


  83. DLKeur says:

    Perfect!


  84. Debra Murphy says:

    Peter, I just activated both this and your case sensitive plugins on one of my client’s sites that has a member’s only area. These just solved two challenges for me.

    Thanks so much for these great plugins. I just love the WordPress community! Cheers.


  85. Loren says:

    Hi Peter,
    I just discovered your plugin and it seems to be just what I need except that I cannot get it to work. I use WP 2.7.1 and the K2 theme. I have a number of non-techie users and would like to make things as simple as possible for them when they log in. But no matter what settings I select on your plugin WordPress always opens to the user profile page when people log in. Any suggestions?
    Thanks,
    Loren


  86. adam says:

    Awsomel! the plug-in work great on WPMU 2.7.1! Thank you for a wonderful plug-in!!


  87. Loren says:

    I figured it out. Conflict with the Themed Login plugin (http://www.jameskelly.org/wordpress-plugins/custom-login-and-registration-forms-plugin/)
    I disabled that plugin and now this one works great.
    Any possibility of combining some of the features of James Kelly’s plugin into this one?
    Thanks, Peter, for a great contribution to WordPress’s CMS possibilities.

    Reply from Peter: I’m glad you figured that out, but too bad about the plugin conflict. Someone else also had this problem before. While I don’t have any plans to expand my redirect plugin beyond its main purpose, it shouldn’t conflict with other plugins as long as those plugins keep up to date with the WordPress framework.


  88. Loren says:

    Hi Peter,
    Thanks for the response. Now that I have the plugin working properly I am liking it better and better. Thanks for your work on this.
    May I add an item to the wish list for this plugin? It would be fabulous if it also addressed logout redirects. That is one of the pieces that I liked from James Kelly’s plugin. Once a user logged out I could avoid having them forced to view the login box again.
    All the best!
    Loren

    Reply from Peter: The WordPress code for the logout process isn’t as flexible as for the login process, but I’ll keep that idea in mind. In the meantime, you can add this code to the plugin for a quick and easy way to send all logouts to the front page (replace the “get_option(‘siteurl’)” bit with any other URL on your site if you don’t want it to be the front page).

    function redirect_logout_front_page() {
    wp_redirect(get_option(‘siteurl’));
    die();
    }

    add_action(‘wp_logout’, ‘redirect_logout_front_page’);


  89. Malcolm says:

    I just installed this plugin and look forward to using it. I see that it uses existing user roles. I want to add roles but so far can’t find a way to do that. Do you know a way to add user roles to a WP installation?

    Reply from Peter: There is a plugin called Role Manager that enables you to create roles. However, I’m not quite sure about whether it’s been kept up to date. There’s also a newer one called Capability Manager.


  90. Kevin says:

    Thanks, Peter. Works great! Is there a way to trap an empty user URL in a comment so a custom message is displayed (e.g. This user has no web site) rather than just the default 404 message from the brower?

    Reply from Peter: I’m not quite sure what you mean (seems a bit off-topic for this post), but you can test for the existence of just “http://” (or lack thereof) at the template level. In other words, you would do a syntax validity check on the URL. Doing an actual check to see whether the URL is valid would take quite a bit more work…


  91. Robert Neuschul says:

    Hi Peter

    Thanks for a great plugin: I have a query for you about modifying the underlying code. Rather than mess of it all by myself I’m hoping you can tell me how to make a mess :-)

    Essentially I have two linked WP installs: one public and one private. The private install lives in a subdomain of the public domain: they are thus two entirely distinct apache/wp installations. They do not share DBs.

    I need to redirect all unauthorised people [non members] back to the home page of the public site. I would prefer not to do this using htaccess/mod_rewrite rules directly in the linux file system since these can be cumbersome to administer.

    Unfortunately your Login Redirect will only work with local URLs, and that means that as far as my private site is concerned the public parent domain isn’t a local site.

    I’m wondering if there’s a way to overcome this limitation; obviously I could hack the code to remove the local limitation, but that is a bit too ‘broad’ and it seems to me that it might be better either to expose a "use nonlocal" option selector, or to find a way to make the plugin recognise when it is installed to a subdomain of a valid parent domain.

    Any thoughts on this?

    Reply from Peter: You can create an “allow” list. Please see this comment.


  92. Robert Neuschul says:

    Peter

    Thanks, whilst that suggested plugin will work it’s still potentially cumbersome to administer, requiring direct editing at the file-system to add/delete or alter entries. Which isn’t a problem in most instances where redirects are unlikely to change much after initial setup, but could be a problem with WP MU where one may need to setup additional redirects with each new blog.

    What I was hoping for was clues about adjusting your plugin to allow non-local redirection entries directly in the plugin management interface; is there a good logical reason for limiting redirects only to local entries?

    TVM

    Robert

    Reply from Peter: That limitation is native to the WordPress redirection code and probably there to prevent unpleasant user experiences in case of a site breach (or even someone manipulating URLs at the client level). You can bypass it altogether by calling wp_redirect($redirect_to); die(); in most places in the function redirect_to_front_page in my plugin where it instead returns that $redirect_to variable. Then from the admin side of things, the quick and easy way is to make the rul_safe_redirect function in my plugin return the $location variable right away. I should make it an option when I get around to releasing the next version of the plugin (as with most things, it just takes… time).


  93. Ashley Yakeley says:

    $_SERVER['PHP_SELF']

    This doesn’t work for me, because I’m redirecting in my .htaccess file. Isn’t there a better way of getting the current page?


  94. Ashley Yakeley says:

    I replaced it with $_SERVER['REDIRECT_URL'] and it worked.


  95. Levani says:

    Is it possible to redirect users not only always on one address, but on previous page, the one where they were before login. (of course if the address is internal)

    Reply from Peter: Check out these comments: here, here, here, and here. Or, starting in version 2.6.0 of the plugin, consider using [variable]http_referer[/variable] as the redirect URL


  96. Don says:

    Peter,
    From everything I’ve read this is a killer plugin. A couple of questions from a compatibility standpoint: 1. are there any issues you know of if I were to also install the DBD Login Style plugin so I can style my login page? 2. Ditto, for SSL or more secure login plugins. Have you worked with any of these that you recommend? Thanks in advance.

    Reply from Peter: Unfortunately I have not had specific experience with such plugins. However, my plugin uses some standard WordPress hooks, so as long as the other plugins retain the login hooks, there should be no problem. You are most likely to have problems if you are using another login-related plugin that has not been updated for WP 2.6.2 or higher.


  97. Tom says:

    Peter, absolutely love the plug-in! I’ve used it to create a Client access side for private projects and whatnot. The only thing I was wondering is how would I go about providing a link back to a specific user’s re-direct page. An example being a link that takes the user back to their specific homepage. Hope this makes sense, again the plug-in has been a lifesaver!

    Cheers,
    Tom

    Reply from Peter: If you are trying to make a link to the redirect URL you’d set up for a specific user using my plugin, you’ll find the username in the “rul_value” field and the URL in the “rul_url” field in the [wp]_login_redirects table. So you can write a database query to get the proper URL for the currently logged in user.


  98. jonobr1 says:

    Peter,

    thanks so much for this plugin. It works like a dream! I’m using it on a project I’m working on http://glitzypoppyhooray.com/ if you’d like an invite I’d be more than honored to send one your way. Thanks again for the plugin!

    -Jono


  99. Molgan says:

    Hi, Thanks for a nice plugin! Setup a paypal "Donate" button that is easily seen. You deserve it man! I will tell the organization I am helping (non-profit) to pay you for it for sure. Thanks again!


  100. majid01 says:

    Hey everyone,
    is it possible to use this with wordpress mu so when someone logs in, it will redirect him to his blog?? (to first/chosen/last blog if that user has many blogs with wordpress mu)

    Thank you for any help :)

    Reply from Peter: Out of the box, no. However, the existing code does offer some sort of framework for that, and this comment can get you started.


  101. steffenrh says:

    Great plugin! First look it works fine with WP 2.8.1. I am just missing one more small feature, for it to be perfect: Is it possible to add a logout URL? E.g. it is pretty annoying, after the user logs out, to leave him in alone with the user / pwd dialog. I just want to redirect the user back to the frontdoor. This is currently not possible with WordPress without some "hacking", right?

    Thank you for the plugin! At least "logging in" now makes much more sense for partially private sites, than dropping the user into the dashboard.

    Reply from Peter: See this comment for my response about log out redirecting.


  102. Iggy says:

    Hi!
    I just stop to thank you for this great plugin. I’ve made the inclusion you sugest to get logout redirect and now I’m happy like a fat cat :))
    I think WP should incorporate this functions in it’s core files.
    Regards!


  103. Tim says:

    hey, thanks so much this plugin is great!….!

    im trying to redirect Subscribers to private pages and was just wondering if you know how this can be acheived? at the moment they redirect but cannot see the page. but if i change them to editors they can see the page (i just dont want them to have those rights)

    thanks Tim

    Reply from Peter: Sounds like you need to edit the WordPress roles and capabilities system via a separate plugin, as discussed a bit in this comment.


  104. Clay Jackson says:

    Hey Peter, thanks for posting this. Is there a way that you know of in WordPress to have a form on the index page that redirects visitors to landing pages relevant to their area code and/or field of interest? Any help would be appreciated.

    Reply from Peter: What you are describing is similar to the basic model of my redirect plugin. You would post to some sort of handler that would look up a table based on the information posted. If there is a relevant match, it would redirect to the URL / page corresponding to what the user entered. If there is no match, it would either give an error or redirect to some catch all page. I don’t think that such a plugin exists, due to the variability in what you would want to do with it, but the framework is not too complicated.


  105. Adam W. Warner says:

    Hi Peter,

    Maybe I’m misunderstanding some intended usage. I am trying to restrict users from seeing they’re profiles upon logging in. I will have a link to this elsewhere. So I just want to redirect all users to the main page.

    I thought the simplest way to accomplish this would be to set the url in the "All other users" area. This works fine, but as an admin user, I would still like to be redirected to the Dashboard. Is it possible to set "All other users besides admin"?

    Reply from Peter: Since the “all other users” rule is the last one to kick in, you can set a rule for the admin user, admin role, or even a capability, and it will take precedence.


  106. Adam W. Warner says:

    Thanks Peter, that works perfectly:)


  107. Hiranthi says:

    The plugin works like a charm, except when there’s the redirect_to var in the URL. Then the login page is just getting reloaded without any errors or anything.
    Once that var has been deleted login (and redirection) work as they should.

    This problem occurs for every role btw (even the ones that don’t have redirect rules made for ‘em).

    Any idea on how I can fix this? I already looked into the plugin code, but couldn’t find anything obvious that causes this.

    Reply from Peter: I actually cannot reproduce this problem. The plugin currently overrides whatever “redirect_to” value is in the URL if there is a configured rule for the user who is logging in. Otherwise, the plugin leaves that value untouched.


  108. Rebecca says:

    Hello all,
    Let me add my congratulations to all the above for a really nice piece of work. I’m fairly new to all this, so can someone help me out please? Like several queries above, I’d like to re-direct subscribers, after they’ve logged in, back to the page they were looking at. My login is in my header and driven by …ehmm … am I allowed to say (*Wishlist*) here? After looking at all Peter’s hints, comments and code above, and having had a play myself, I’m still not getting it to work for me… Please, can someone spell it out ‘Peter’s-Redirect-For-Dummies’ style? Thank you in advance!


  109. KCP says:

    Hi Peter,

    This looks like it is exactly what I need. Problem is I can’t install the plugin. After install I get the message:

    WordPress database error Field ‘rul_value’ doesn’t have a default value for query INSERT INTO `wp_login_redirects` (`rul_type`) VALUES (‘all’) made by activate_plugin, do_action, call_user_func_array, rul_install

    I used your version 1.7.0 on WP 2.8.4 running on IIS and MySQL 5.1.37.

    Any help would be highly appreciated.

    KCP

    Reply from Peter: Thanks for pointing that out. I’ve now released Version 1.7.1, which should be more compatible as it states a default value for all database fields.


  110. KCP says:

    Hi Peter,

    Thanks for the update!
    Unfortunately this caused a new problem:

    WordPress database error BLOB/TEXT column ‘rul_url’ can’t have a default value for query CREATE TABLE wp_login_redirects…

    I have corrected it myself by changing line 753 of wplogin_redirect.php to: `rul_url` longtext NOT NULL ,

    Now it activates like a charm.

    Anyway, thanks again and keep up the good work!

    KCP

    Reply from Peter: Thanks. I was overzealous in the fix — of course a longtext datatype cannot have a default value! This is now… fixed!


  111. Jess says:

    I just installed it and it works beautiful. Exactly what I needed. Thanks!


  112. Srecko says:

    Hi,
    I installed your plug in and it works perfectly.
    The only comment I have is that options for configuring the plugin the Profile page is showing if the user is Editor, and he/she can change all the settings.
    I believe that it should be visible only if the user is Administrator

    Srecko

    Reply from Peter: You can change this by replacing:
    add_options_page(‘Login redirects’, ‘Login redirects’, 7, ‘wplogin_redirect.php’, ‘rul_optionsmenu’);
    with:
    add_options_page(‘Login redirects’, ‘Login redirects’, ‘install_plugins’, ‘wplogin_redirect.php’, ‘rul_optionsmenu’);
    (Replace “7” with either “9” or any capability that only the admin user has)


  113. Tamitha says:

    I am having trouble with this plugin when new users register using Gigya. It pops up the message "logging in please wait" but it never goes anywhere after that. Your plugin works fine for gigya login of a user who is already registered but not for immediate registration.

    Any suggestions?

    Thanks so much!

    Reply from Peter: Gigya bypasses the normal WordPress redirect process. I’ve added support in version 1.9.0 of my plugin to have Gigya redirect to an intermediary URL, where my plugin will then redirect the user to their final destination. See the $rul_use_redirect_controller setting in my plugin for more information.


  114. jeremiah says:

    Just to confirm what tamitha says, when I disable your plugin, Gigya works perfect. When i enable your plugin, Gigya stops working.

    Unfortuante because the partnership between the two plugins makes for a BEAUTIFUL combination if it would work smoothly. Glad to help you see the issue if you’d like

    http://www.boondogglen.com/blog/login.php

    Right now your plugin is deactivated, if you’d like I can activate it and you can see what conflicts?

    Reply from Peter: I’ve added support in version 1.9.0 of my plugin to have Gigya redirect to an intermediary URL, where my plugin will then redirect the user to their final destination. See the $rul_use_redirect_controller setting in my plugin for more information.


  115. eric B says:

    I tried this plugin, but everytime i try to change/modify then save a setting it redirects me to the login page, with the redirect url in the URL, but it doesn’t save.. I am also using another plugin to move the login page to a normal template style page (customize your community CYC). maybey there is a conflict with it?

    Reply from Peter: Other plugins that change the default WordPress sign in method can possibly clash with this one, as this one relies on the default WordPress login hooks. You could certainly tweak things to work but it would be different for every custom setup.


  116. Kahil says:

    I too cannot see the link under settings. I saw it once, made some settings and now I cannot see it at all any more. I even tried it on a fresh install and nada. what should the URL look like?

    Reply from Peter: URL should be yoursite.com/wp-admin/options-general.php?page=wplogin_redirect.php.


  117. Jason says:

    Doesn’t work with WordPress 2.9. I get a "Plugin could not be activated because it triggered a fatal error."

    Reply from Peter: What version of the plugin are you using and is there a specific error message you can share? The plugin has been tested with WordPress 2.9 and there shouldn’t be a problem other than possible clashes with other plugins (and the risk in that case is no more so than any other plugin).


  118. Wing says:

    I downloaded and tried your plugin, but could not re-direct a user login to a private page. The error is page not found.

    Is it a limitation or something else?

    Reply from Peter: No, there should not be a problem as long as the URL you entered is correct and the user can actually access the page. My plugin leaves the permission checking up to WordPress and does not interfere there.


  119. Frac says:

    This is just this ticket. All I use it for is to have new "subscriber" users redirected to the home page rather than the dashboard when they log in.

    They can still go to their dashboard using the "Site Admin" link. I found that new users were confused when the "site" disappeared and this weird "control panel" showed up instead. Particularly if they’re were just setting up a quick account to leave a comment.


  120. Matt says:

    Do I need to setup a redirect for the admin? Because when I set it up for subscriber, and when I try to login as admin, I cant. It keeps showing me the login.php page. I need to go into my FTP and change the foldername to something else in order to get back in as admin.

    Reply from Peter: No, you shouldn’t need any default or admin redirects. I can’t replicate your problem, but it might be due to a clash with another plugin, especially if that plugin overrides any core WordPress functionalities.


  121. piggy says:

    hi! thank you so much for this plugin! this is exactly what i need right now :)


  122. Faye says:

    Great plugin Peter, and thank you for your work on it. I’m in a similar situation to another commenter in that in addition to users being redirected to specific pages on login, I’d also like them to be able to get back to their specific page with a link at any time whe they’re logged in. I’m no kind of coder at all, so writing a database query is beyond my ken – can you advise? Many thanks!

    Reply from Peter: Please see this comment


  123. Roger says:

    Hi Peter

    Thanks for the great plugin.

    I too want to be able for the user to navigate to other parts of my site and then get back to their specific login page. I have read each and every comment here and tried to write an SQL Query but it is not quite working. I wish to use it Outside the Loop in the header.php

    Here is where I am up to…

    ——————————–
    <?php
    $rul_db_addresses = $wpdb->prefix . ‘login_redirects';
    global $wpdb, $rul_db_addresses;
    global $current_user;
    get_currentuserinfo();

    $usergallerys = "SELECT * FROM $rul_db_addresses WHERE rul_value = $current_user->user_login ";
    $usergallery = $wpdb->get_results($usergallerys, OBJECT);
    echo $usergallery->rul_value;
    ?>
    ——————————-

    Am I on the right track????

    Cheers and thanks in advance for any help you can offer.

    Rog


  124. el_Vania says:

    Guy, this is the plugin I’ve been searching for years.
    Works silky and fine… flawlessly.

    Thanks for this masterpiece of plugin, mate.

    Keep up the good work.

    Greetings.

    Ivan.


  125. Darren says:

    Thanks for this great plugin.

    I did just discover that "Custom Login Logo" plugin conflicts with this plugin though. EG: If you visit a page that requires login (say wp-admin/) it redirects to the login page, but fails to redirect back and simply loops the login page without an error.

    Thanks,
    -darren

    Reply from Peter: My plugin simply makes use of a normal WordPress hook, so if the other plugin is trying to rewrite some core WordPress functionality, there’s not much that can be done to cater to plugins like it on a general basis. I’d suggest looking at other ways to customize your login page, such as this CSS tip.


  126. Roger says:

    Aha

    Problem Solved!!!!…. If you wish to redirect users back to their original login page the following code appears to work (at least Outside of the Loop). You will need to format it for your particular case but here it is…..

    _______________________
    <?php if (is_user_logged_in()){ ?>
    <?php global $wpdb, $rul_db_addresses, $current_user;
    get_currentuserinfo();
    $user_home_page = $wpdb->get_var(‘SELECT rul_url FROM ‘ . $rul_db_addresses .
    ‘ WHERE rul_type = \’user\’ AND rul_value = \” . $current_user->user_login . ‘\’ LIMIT 1′); ?>

    <a href="<?php echo $user_home_page;?>"><?php _e(‘User Home Page’);?></a>
    <?php } else { ?>
    Do something else if user not logged in
    <?php } ?>
    _______________________
    Cheers Rog
    http://www.popcornphotography.com.au


  127. Peter G says:

    Thanks so much for this plugin! I had been hard-coding some of the same functionality for months now, but never had such an easy-to-use, configurable way of doing it.

    At first, I did experience the same issue as eric B. Every time I tried to update the plugin settings I was redirected back to my login page. After some time spent eliminating possible plugin conflicts I realized the issue was an incorrect form URL (for my site at least).

    wplogin_redirect.php has four lines similar to the following:
    <form name="…" action="<?php print $_SERVER['PHP_SELF'] . ‘?page=’ . basename(__FILE__); ?>" method="post">

    This resulted in a post to /wordpress/wp-admin/options-general.php?page=wplogin_redirect.php. While my blog does physically reside in the wordpress directory, it is treated as the root of the site through URL rewrites.

    My solution was to make the following change to the lines in question:
    <form name="…" action="<?php print $_SERVER['REQUEST_URI'] ?>" method="post">

    i.e. "$_SERVER['PHP_SELF'] . ‘?page=’ . basename(__FILE__)" becomes "$_SERVER['REQUEST_URI']"

    I hope this helps someone out.

    Reply from Peter: Thanks for this. For version 1.7.3 I took a slightly different approach — just eliminating the $_SERVER part altogether.


  128. Zoinks! Graphics says:

    Pretty awesome plugin… Works great with Hide Admin Panels on WP 2.9.2 !


  129. shawn says:

    I am trying to use this plugin with buddypress to redirect a user to their activity page after signing in.

    I only want this for subscribers.

    What I can’t figure out is what to put into the url, because each persons activity page is different

    example:
    http://mywebsite.net/members/admin/activity/

    the ‘admin’ is the users wildcard…

    ideas?

    Reply from Peter: Starting in version 1.8 of the plugin, you can put this as the URL: http://mywebsite.net/members/[variable]username[/variable]/activity/


  130. Rob says:

    Fantastic plug-in. Only hitch was because the mysql user doesn’t have CREATE TABLE privileges. I checked out the source and pulled the CREATE TABLE SQL and did this manually.

    Might be helpful to add to the plugin – check tables, if table doesn’t exist, don’t show form, rather show info on how to create the table.

    Aside from that, worked perfectly and the PHP is very neat.

    Thanks!

    Reply from Peter: Thanks for the feedback. I will add the table details to a “Troubleshooting” section in the post.


  131. Ben says:

    Great plugin, just what I needed so subscribers don’t get confused when they log in to view content. Thank you : )


  132. David says:

    Peter thank you so much for the great plugin. 1.80 is awesome.

    For Shawn above, if you upgrade to 1.8 there is a place for a username variable so you would redirect to:

    http://mywebsite.net/members/[variable]username[/variable]/activity/


  133. Jamie says:

    This is an excellent plugin. Simple to use, but does exactly what it should.

    I’m not sure people realise how tricky this could be – I work with both drupal and joomla. It’s possible in Drupal (but very tricky), and I’ve never found a way to do it at all in Joomla.

    Congrats.


  134. MikeonTV says:

    Still no logout function? It seems silly that my users still have to see the wordpress login screen when logging.

    Reply from Peter: See this comment. You could also write your own function that completely overrides the wp_logout function.


  135. Jonathon says:

    Peter, Thank you for this plugin, AWESOME!

    @MikeonTV, maybe check out Smashing Magazine’s post. Number 3 in their WordPress powertips "3. Embedding a log-in form that returns to the current location" might do the trick, checking it myself now.

    http://www.smashingmagazine.com/2009/07/02/power-tips-for-wordpress-template-developers/


  136. Pete says:

    awesome, awesome plugin! what im wondering is how i can send people to a different wp system and be authenticated on the other end. for example, there are three sites: a.com, b.com, c.com.

    i want both b.com and c.com to be able to login through a.com as well as their respective sites. assuming that the user sets the same username and password on both ends (a.com and say b.com), how can i pass those login credentials from a.com to b.com/c.com so they don’t have to login again on the external sites?

    basically, i want clients to be able to login through my own website to access their files vs making them login through their own wp-login. login through both both ends (a.com and the external b/c.com) would be essential just in case the parent a.com goes offline for whatever reason (they’d still be able to access login through their own server).

    thoughts?

    Reply from Peter: This doesn’t really pertain to my plugin and I haven’t researched much into this topic. If your sites are all sitting on the same server, you could start here: http://techblog.touchbasic.com/html/single-unified-login-for-multiple-wordpress-2-8-installs-in-subdirectories-using-cookies/


  137. Florian says:

    Hey Peter,

    Thx for the great Plugin! I would like to redirect the users directly after the registration-process to one of the pages. (Not to the backend-login as default) Is that possible with your plugin? And how does it works? I use WP 2.9.2 with sipmle:press-forum and this is my last chance to get a ‘clean’ registration. So your help was very useful! THX a lot!

    Reply from Peter: If you’re using a version of WordPress prior to 3.0 and are using the default registration process (wp-login.php?action=register) it looks like the only way to change the post-registration redirect URL is to edit wp-login.php (look for the section under case: ‘register’)


  138. Voogah says:

    Awesome plugin!

    I have been using it for several months and it has worked great.

    However, I am now trying to have it redirected to a custom page that is needing the $current_id global variable. This works fine in IE but not in Safari, FireFox or Chrome.

    After messing with the php code on my pages for weeks I finally learned that it has to do with the redirect. If I take the redirect out and have it go to the backend and then link it to my page it finds the global!

    Do you have any ideas on how to get the Global variables after your redirect plugin?

    Thanks

    Reply from Peter: If you’re talking about getting the ID of the page you’re on when viewing the page, there’s nothing in the redirect plugin that is preventing that from happening. The redirect plugin allows a completely new page reload. Sounds like there’s something else going on.

Speak your mind

April 10th, 2010 update: Due to the number of comments on this post, please use the login redirect questions and comments forum from now on. Thanks!