Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How do I to override login redirect on specific pages?

Answer:

I’ve figured this out myself.

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

// Plugin by http://wordpress.org/extend/plugins/peters-login-redirect/
// Solution by http://www.dominornovus.com

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:

http://www.dominornovus.com/2011/11/14/restrict-peters-login-redirect-to-same-page-redirection/

Related Posts:

  1. wordpress custom login successful redirect hook
  2. How can I check if on specific plugin generated page or child
  3. How to use login_redirect with a user capability
  4. Janrain/Simple Modal under Redirected Domain
  5. WordPress Admin login redirect to homepage
  6. How to create WordPress login for different users, with different roles?
  7. Login cookies set as wrong domain
  8. BbPress Register Page in Breadcrumbs
  9. bbPress plugin: forum lists not showing in correct order? [closed]
  10. Login Customizer doesn’t change the background of the register form
  11. easy steps to make front end form without plugin
  12. Removing Automatic Redirects Without Plugin
  13. Change wp-login to custom URL login page
  14. Duplicate New User Registration notices (BuddyPress and bbPress both installed)
  15. WordPress 4.3 broke meta redirect (with url params plugin)
  16. Edit Permalink Structure For Custom Post Type or Modify .htaccess?
  17. Login problem after installing my written plugin [closed]
  18. Too many login attempts
  19. Get ‘Headers already sent’ error for the plugin I am creating when I try to login
  20. Mask and Track Outbound Links
  21. Custom Login Page — wp_signon Headers Already Sent?
  22. How can I redirect some pages to new subdomain? [closed]
  23. Theme My Login Shortcode Doesn’t Return Anything
  24. Add to array, redirect and display
  25. Possibility to login without password
  26. how do i change my website facebook login button to another text immediately user login? [closed]
  27. WordPress unable to write files in the server
  28. Conditional custom redirect
  29. Custom PHP Page Using WordPress login
  30. how to set parent forum link to menu page?
  31. How to Use the Filter “sidebar_login_widget_form_args”
  32. Making the ‘add to cart’ button redirect to PayPal
  33. How to completely hide a WordPress/BuddyPress Install? [closed]
  34. Manage PDF downloads and protected pages
  35. How do I determine if the user who registered is not spam?
  36. PHP mobile redirect Endless loop
  37. How to force load a page in plugin?
  38. If I use an alternative login (e.g. CAS or other SSO) plugin, is my site protected from the recent brute force login attempts?
  39. login in wordpress using gmail account
  40. wp redirect 301 not working in wordpress page
  41. Preserve Search engine index while shifting to new Domain
  42. How can I replace content on site generated from plugin without changing plugin
  43. Linking form to user meta fields
  44. WordPress Multisite Profile Picture Sync Error with Nextend Social Login Plugin
  45. Redirect unloggedin users
  46. Plugin or ways to limit number of users logging in the website,
  47. force logged in user to stay in the dashboard
  48. login form should redirect to register page for in 1st login next time it should redirected to home page
  49. Identify User Language, Redirect to the corresponding page and Save the chosen language as Cookie
  50. www redirects to another directory in wordpress
  51. Hidden permalink different from displayed permalink
  52. redirect to homepage once action is completed
  53. Display value of the GET parameter in a new URL page
  54. Share login credential with QR code
  55. Redirect to a page while maintaining search query parameters without causing an infinite loop
  56. Which membership plugin for a simple sign in? Personal areas for customers
  57. Discern a specific plugin’s action hooks
  58. Can’t add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS
  59. How to update all in-site redirect URLs to destination URLs at once
  60. Login/password protected “client page”
  61. How to send new visitor to a splash page for only one time in wordpress?
  62. return bbp_get_topic_author_id as integer
  63. Why is my site still showing insecure icon even if I have SSL certificate?
  64. Forum creation with bbpress and front end
  65. Reverse count page view and show on other page
  66. https rewrite not working for All in one security Brute force > rename login url
  67. On button click, redirect users to registration page instead of another page
  68. How can I show login popup when user clicks on download button
  69. When the user entered an unauthorized url redirect to login page
  70. How to show private pages based on a user’s role?
  71. redirect to a custom page
  72. Why does WordPress use cookies for /wp-admin and /wp-content/plugins for non-admin users [duplicate]
  73. .htaccess file doesn’t work, with hundred tries
  74. Identify if the_post hook is being called from the admin post list
  75. using wordpress login details for other website / application / forum?
  76. Infinite 301 redirects after definitions in “Redirections” plugin?
  77. wp_signon returns user, in popup window, but the user is not logged in
  78. How to Create Custom Dashboard for my Laundry Website?
  79. wp_login_form() ignoring login_form action hook
  80. User content database [closed]
  81. Clone a Post Tite and Custom Field into Custom Post type
  82. Direct URL to a template via plugin
  83. Auto-login from backend
  84. AJAX login without a plugin does not work. when add a action to function.php
  85. Plugins effecting layout & login
  86. Redirect default login page to a custom page [duplicate]
  87. How to redirect from plugin page
  88. wp-admin will not redirect to wp-login.php
  89. Template redirect inside of plugin not redirecting
  90. Adding google authenticator and use only email address of user
  91. Can’t redirect to previous page after using GET
  92. Adding a Filter to Sidbar Login Plugin to Change Login Button Lable
  93. First argument is expected to be a valid callback for cp_admin_init and _canonical_charset
  94. how to protect wordpress website
  95. Need to change contact email depending where user is from
  96. Redirect url in plugin to somewhere else?
  97. WordPress ReAuth =1 Loop with wpCAS
  98. HTTP Error 403 When Trying to Login
  99. Advice on setting up private site
  100. Checking url from plugin [duplicate]
Categories plugins Tags bbpress, login, plugins, redirect
Single page template
Calling Custom Post Meta

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress