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:

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.

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.

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 history2.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.

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.

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

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.

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.

@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.

@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.

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.

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?

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.

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!

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.

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

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.

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.

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.

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

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…

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.

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

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.

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.

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).

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.

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!

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?

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.

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–

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:

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.

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:

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!

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.

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.

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.

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).

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″

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.

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!

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.

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

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.

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).

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.

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…

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.

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).

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.

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.

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!

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.

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!

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.

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.

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.

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.

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!

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)

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.

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.

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.

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).

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.

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.

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.

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!

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

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.

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…..

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).

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">

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/

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’)

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

Contact Me

Comment on any of my posts to contact me. Your e-mail address will only be visible to me and not to the public. If you want to contact me in a more private manner, e-mail peterkeung.biz. Hire my web consulting services at Mugo Web.