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

Custom Login page, redirection and restrictions

the redirect doesnt have a lot to do with browsers, have you try to clean firefox cache, it can be that.

also using ‘/distributors’ on users after succefully log in as url can sometimes not work, can redirect instead for the url link plus ‘/distributors’, is safer to use

home_url().'/distributors';

I use this function in functions.php to redirect on login

// redirects user after login
if (! function_exists('ctm_login')) {
    add_action('wp_login', 'ctm_login');
    function ctm_login(){wp_redirect(home_url());exit;}
}

so in your case should be something like

// redirects user after login
if (! function_exists('ctm_login')) {
    add_action('wp_login', 'ctm_login');
    function ctm_login(){
       $url = ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : home_url().'/distributors';
       wp_redirect($url);
       exit;
    }
}

this is the redirect after login, but one question, and if someone goes to the url and write “www.yourSite.com/distributors” will the page load?…

Related Posts:

  1. send popup after wp_redirect()
  2. How to use nonce with front end submission form?
  3. Adding “Remember Me” in custom login
  4. How build a custom login/register form with error handling?
  5. PHP – redirect https to http and www to non-www
  6. How to redirect users to custom lostpassword page?
  7. WordPress 4 invalid username special charachters issue
  8. Remove “Remember Me” from login form
  9. Check if current page is wp-admin
  10. Change WordPress default registration error text [Error: This username is invalid because it uses illegal characters. Please enter a valid username.]
  11. Anyway to output the registration form like the login form with wp_login_form()?
  12. Overriding WP login credentials
  13. Wp-login appears White Screen, Error: Cannot modify header information
  14. wp_redirect only works on main site and not on other sites
  15. Troll the hackers by redirecting them
  16. how to prevent wordpress admin from logging in via woocommerce my-account page
  17. How to hook a logout funtion for specific usr role in wordpress?
  18. Is this a correct usage of ob_start() in my WordPress project?
  19. How do I create a function that modifies a message in the wp-login.php file?
  20. Logout redirects to default page
  21. Manually Create PHP Page For A Redirect
  22. Admin Menu new tab external link
  23. Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
  24. random post redirect in wordpress with a .php file
  25. Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
  26. Infinite loop when logging out using custom login form
  27. WooCommerce – template_redirect if is_checkout AND order has been paid?
  28. Redirect user to a custom url after logged in
  29. How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
  30. Detect what link user clicks and Redirect to a specific page for logged in users only
  31. Force CSV download with template_redirect
  32. Cannot modify header information – headers already sent
  33. Redirect users by role to custom pages
  34. How to hide header and footer from page template
  35. Frontend redirect after delete post in wordpress
  36. Redirect posts to post editor page based on query string
  37. How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
  38. Processing data and redirecting with query string
  39. images in wordpress themes
  40. Nav Menu Display
  41. split searchresults into different topics?
  42. WordPress & PHP sessions
  43. Get current WordPress page then add #post ID to the end
  44. WordPress redirect on login
  45. WordPress Plugin Receive a Link
  46. Adding a unique class to wp_nav_menu
  47. How can I add more code to this?
  48. How to extend the page editor?
  49. Save Option on Database
  50. .htaccess on multisite and roots theme?
  51. Get permalink for a post from inside WordPress and route to a related site
  52. Sidebar doesnt get updated?
  53. How does one programmatically manage posts from a external php script?
  54. Edit the Publish Widget Options
  55. how to set category name for a post
  56. Change order that the menu is generated with wp_list_pages
  57. Move wordpress sidebar on homepage up to new position
  58. How can I print out a single stylesheet or javascript link?
  59. Determine if only one image attached to a post/page
  60. Converting Menu Links to List Elements
  61. Cannot Upload Custom Header Image into WordPress Dashboard
  62. Force string into signup form
  63. When I use rewind_post() it shows menu items in my loop
  64. Problem using explode inside add_shortcode() callback funciton [closed]
  65. Code that displays images – images get shown multiple times
  66. I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
  67. How to call a specific value within the functions.php file?
  68. Error on Include php:/usr/share/pear
  69. custom data in url
  70. How to define template directory in this widget code
  71. Dynamically append custom post type to end of url
  72. WordPress: Create A Widget to Accompany Plugin
  73. Warning: Cannot modify header information (with a twist)
  74. Automatically load WordPress page on server every XX hours
  75. How to use custom fields to replace top-level parent title with an image using wp_list_pages?
  76. Fix My Custom Function: Remove Automatic
  77. PHP Puzzle: Unique Styles with PHP loop
  78. Change default comments form title [duplicate]
  79. Programmatically change post templates? [duplicate]
  80. custom contact form no longer working (because of 3.2?)
  81. Catchable fatal error in appcloud free theme by Tokokoo
  82. Add Column to Term Database
  83. File Upload with Server in safe_mode
  84. I want Page titles and excerpts to show up on home.php in certain order
  85. WP plugin updates [duplicate]
  86. Hide a nav menu item based on get_user_meta results
  87. Custom Archive Page
  88. How to change a specific character in a theme option value – replace a space with a plus sign
  89. Crop images in both sides on wordpress [duplicate]
  90. 2 small questions: How to redirect to a created page & show that pages title in wp, bp
  91. Custom query_posts() parameter
  92. How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
  93. Incomplete term slugs output from a foreach loop with get_the_terms
  94. Posts sortable column not sorting properly for custom field numbers
  95. How to set if meta_value is lower < than other meta_value in a get_posts array?
  96. How to include support for all page types, calendar urls, archive, etc
  97. How can I add page template after post of a post type?
  98. Custom Shortcode with Dynamic Button
  99. Is it possible to display conditional HTML based on page name in wordpress?
  100. Global variables and re-use
Categories PHP Tags php, template-redirect, wp-login-form, wp-redirect
meta_query compare “=“ returns nothing when it seems it should
How to remove Login from in my account page

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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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