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

Reloading page with a query string upon login for admins

Try using the filter hook:

function user1462_login_redirect( $redirect_to, $request, $user ) {
    global $user;

    if ( isset( $user->roles ) && is_array( $user->roles ) ) {

        if ( in_array( 'administrator', $user->roles ) ) {
            return $redirect_to . '?message=hiadmin';
        } else {
            return home_url();
        }
    } else {
        return $redirect_to;
    }
}
add_filter( 'login_redirect', 'user1462_login_redirect', 10, 3 );

Related Posts:

  1. Can I programmatically login a user without a password?
  2. What is $interim_login?
  3. Adding extra authentication field in login page
  4. What exactly is ReAuth?
  5. Login members using web services
  6. Disable WordPress 3.6 idle logout / login modal window / session expiration
  7. How to pass users back and forth using session data?
  8. How do I use add_action from a class method?
  9. Need to execute a cron job
  10. Action wp_login_failed not working if only one field is filled out
  11. wp_login action hook not working
  12. how to update current logged user username
  13. Validate Custom Login field
  14. Calling wp_signon doesn’t log the user in
  15. How to implement Google reCaptcha without installing a plugin?
  16. Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?
  17. Are there ways of logging in that bypass wp-login.php altogether?
  18. How to display username and password after registration
  19. How to modify the action attribute of the wp-login.php?action=register form?
  20. Two factor authentication
  21. How to generate “WP_Error” Object for user login?
  22. add_action(‘init’) not work
  23. Allow Access to Home Page and Login Screen but Nothing Else (unless logged in)
  24. Where is the php file, that does the checks for login information?
  25. I want login using email not username wordpress front end
  26. Custom login modal page action
  27. WordPress authentication using custom php?
  28. authenticate user without redirecting
  29. Multiple issues with Ajax login function due to browsers and cookies
  30. How to post frontend login form to a different authentication script from wp-login?
  31. Custom user roles are unable to login
  32. Using WordPress login for a non word-press website
  33. Extend Cookie with auth_cookie_expiration not working
  34. Can we start session from another php site to wordpress blog site?
  35. Opening protected page with cookie?
  36. Is there any reason why there’s no “login_header” action at the login page?
  37. Handle POST request sent from an external site for login?
  38. External Authentication
  39. Login and register by API
  40. index.php file shown when trying to load wesite
  41. Custom login form
  42. Make my wordpress blog remember my login “forever”
  43. How to check in timber if user is loggedin?
  44. Stop WordPress from logging me out (need to keep me logged in)
  45. Does wp_logout_url() destroy a session? (Logging out question)
  46. How to keep always logged in development environment
  47. Add Confirm Password field in wp-login.php Password Reset page
  48. Using `auth_redirect` : keeps asking me to login even when I’m logged in
  49. Gaining Login Access via the Database
  50. send users logging in from wp-login.php directly to home page of site, rather than dashboard
  51. Changing Login Logo
  52. Get user ID after logging in
  53. How can I retrieve the username and password from my WordPress installation?
  54. User Directory without a Plugin
  55. wp-admin seems to be redirecting
  56. Custom Connect to Facebook, problem logging in/logging out
  57. WordPress login urls
  58. Use WordPress with a custom OAuth2 provider
  59. WordPress Login page trashed
  60. Change Favicon on Login Screen?
  61. What’s hook to use immediately after a user is authentcated [duplicate]
  62. wp-login gives 404 error, but wp-admin is working fine
  63. Custom login message for single post pages only
  64. Password protect media attachment – share across guests
  65. Password reset – Disabled for LDAP accounts
  66. Replace dash with space in username on login
  67. Autologin only working the second time
  68. Completely replacing the login form
  69. Single sign on with custom site
  70. By registering always make uppercase the first letter of the login
  71. Best option to implement external register/login to WP from self-made API
  72. I cannot login and am getting this error message. .
  73. Can I Get User ID at Login?
  74. WordPress SSL not working [closed]
  75. what is the best and safest way to allow users to register to site
  76. Sharing a logged in session with a custom subdmain site?
  77. How to redirect a unique link based on login status
  78. MAMP localhost wordpress site, not possible to sign in, username and password are correct
  79. Login issues wordpress page
  80. check the first login for specific roles
  81. Make WordPress User Name be the Company Name when Registering (not the default ‘first name’ last name’ email address’)
  82. Why do I have a reauth=1 redirection loop when I try to log in to WordPress hosted on AWS Fargate?
  83. Confused – can’t access wordpress dashboard or site that has been published
  84. wordpress login loop and session problem
  85. unable to Login to Admin
  86. ERROR: Cookies are blocked due to unexpected output – ultimate solution
  87. Fatal error: Call to undefined function get_plugin_data()
  88. Make WordPress User Name the Email Address When Register
  89. Users redirected to old site
  90. WordPress Login / SSL = Code Question
  91. Save user login date
  92. Login with Username (or Code) only
  93. wp_signon gives error insufficient_permissions
  94. Is there a way to give users the option to log in to their favorite group on login? [closed]
  95. Securely log in a user without a password using a link?
  96. Logging in takes a few refreshes to show you are logged in, is this a cache issue? [closed]
  97. How to add a new link to the default register form’s footer links?
  98. Direct access to site when log in
  99. Can not login after moving to cloudflare and adding rules
  100. Inconsistent login state
Categories login Tags actions, authentication, login
using get_template_part() inside a widget and passing variables
Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied

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