Arrow

How to restrict to same page redirection for sidebar widget login | Peter's Login Redirect | Forum

Back to the login redirect plugin page
 
Current User: Guest
Search Forums:


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

How to restrict to same page redirection for sidebar widget login

Reply to Post Add a New Topic
UserPost

11:49 am
November 14, 2011


Dominor Novus

Guest

Many folks online appear to be having difficulty with this so I've decided to share my solution:

Add the following code to your theme's functions.php file:

I posted this in the WordPress.org forum for the plugin too.

// Plugin by <a href="http://wordpress.org/extend/pl…..&quot; rel="nofollow">http://wordpress.org/extend/pl…../a&gt;
// Solution by <a href="http://www.dominornovus.com&quot; rel="nofollow">http://www.dominornovus.com&lt…../a&gt;

function login_widget_redirect( $empty, $redirect_to, $requested_redirect_to, $user )
{
// If the referring page contains "/forums/"…
if (stripos($_SERVER['HTTP_REFERER'],'/forums/') !== false)
{
$referringpage = $_SERVER[HTTP_REFERER];
return $referringpage;
}
//Otherwise, check the referring page contains "/blog/"…
else if (stripos($_SERVER['HTTP_REFERER'],'/blog/') !== false)
{
$referringpage = $_SERVER[HTTP_REFERER];
return $referringpage;
}
// Otherwise, default to the plugin's redirect settings…
else
{
return false;
}

}

add_filter( 'rul_before_user', 'login_widget_redirect', 10, 4 );

This will effectively disable the plugin's redirect settings anytime a user logs in from a forum or blog page. The standard wp-login.php page will inherit the plugin's redirect settings.

You can find a detailed explanation of the code at my blog:

restrict-peters-login-redirect-to-same-page-redirection

2:44 pm
November 14, 2011


Peter

Admin

posts 732

Thanks for sharing the helpful code example!

Reply to Post

Reply to Topic:
How to restrict to same page redirection for sidebar widget login

Guest Name (Required):

Guest Email (Required):

HTML Editor
Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
1 + 7