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. How to modify username before logging in?
  42. In Django, how do I know the currently logged-in user?
  43. Is there a hook that runs after a user logs in?
  44. Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
  45. Is there any way to rename or hide wp-login.php?
  46. How to login with email only no username?
  47. How can I redirect user after entering wrong password?
  48. Increase of failed login attempts, brute force attacks? [closed]
  49. Login page ERROR: Cookies are blocked due to unexpected output
  50. Separate registration and login for different roles
  51. SSO / authentication integration with external ‘directory service’
  52. Preventing session timeout
  53. How reduce wordpress login session timeout time?
  54. How to prefill WordPress registration with social details
  55. Check for correct username on custom login form
  56. How to Change the Default Home Page for the WordPress Dashboard?
  57. Disallow user from editing their own profile information
  58. I can’t access my site via wp-admin
  59. ‘Password field is empty’ error when using autofill in Chrome
  60. Removing username from the ‘wordpress_logged_in’ cookie
  61. How to show ‘login error’ and ‘lost password’ on my template page?
  62. How do I require authorization / login to view a specific set of posts / pages?
  63. Custom login form
  64. How to prefill the username/password fields on the login page
  65. wp_signon returns user, but the user is not logged in
  66. Prevent wp_login_form() from redirecting to wp-admin when there are errors
  67. Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
  68. wp_signon() does not authenticate user guidance needed
  69. What are the differences between wp_users and wp_usermeta tables?
  70. WordPress auto login after registration not working
  71. Make my wordpress blog remember my login “forever”
  72. How to check in timber if user is loggedin?
  73. How do I change the language of only the login page?
  74. Stop WordPress from logging me out (need to keep me logged in)
  75. Woocommerce registration page [closed]
  76. How to disable autocomplete on the wp-login.php page
  77. Share login data/cookies between multiple installations
  78. Synchronize WordPress user accounts across multiple domains and installations without using WordPress MU
  79. How do I change the logo on the login page?
  80. Why does WordPress hide the reset password key from the URL?
  81. Is it possible to sign in with user_email in WordPress?
  82. How to use current_user_can()?
  83. Avoid to load default WP styles in login screen
  84. WordPress registration message
  85. How to fake a WordPress login?
  86. how to display the wordpress login and register forms on a page?
  87. Does wp_logout_url() destroy a session? (Logging out question)
  88. How can I send a welcome email to a user AFTER they login for the first time?
  89. Can not login with correct username and password
  90. Website Visible only to Registered users
  91. How can i increase the login expiration length?
  92. How can I log a user out of WordPress before the page loads?
  93. How to remove the WordPress logo from login and register page?
  94. How can I add a custom script to footer of login page?
  95. Brute force attack?
  96. Customize wp_new_user_notification_email()
  97. How to check WordPress website username and password is correct
  98. Login email after registration never sent or received
  99. Run javascript code after wp_login hook?
  100. How can I create a separate blog that is private?
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
  • 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