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

Redirecting or displaying a message on first login

here’s an example that hooks login_redirect and checks when their account was created, then redirects them to a url of your choice if it’s been less than 48 hours:

function my_redirect( $to, $requested, $user ){
    if( !isset( $user->user_login ) ){ // we only want this to run when credentials have been supplied
        return $to;
    }
    $regtime = strtotime($user->user_registered);
    $now = strtotime("now");
    $diff = $now - $regtime;
    $hours = $diff / 60 / 60;
    if( $hours < 48 ){
        return "/somepage/"; // it's been less than 48 hours, redirect to message.
    } else {
        return admin_url();
    }
}
add_filter('login_redirect', 'my_redirect', 10, 3);

Related Posts:

  1. Is it possible to sign in with user_email in WordPress?
  2. Website Visible only to Registered users
  3. moving server can not login
  4. how to update current logged user username
  5. How can I allow access to two user accounts using one login?
  6. Share user table from WP with Drupal
  7. Password protect media attachment – share across guests
  8. WordPress login problem
  9. Good way to block users within a multisite setup without deleting them?
  10. Reset Password policy
  11. WordPress Login redirection according to user role
  12. How do you manage your pages or functions that require logged-in users?
  13. How to restrict access to a single for users I’ve authorized? [closed]
  14. Delete a user from frontend
  15. Sign in with social media accounts without creating a WP account [closed]
  16. define two login page url
  17. Custom user roles are unable to login
  18. How to password protect pages in WordPress
  19. How to lock WordPress front-end with login and password?
  20. Creating Custom Login Form Where Password Field is Dropdown Menu
  21. determine active user browser at the same time
  22. WordPress change role from administrator to author by itself (automatically)
  23. In Django, how do I know the currently logged-in user?
  24. Can I programmatically login a user without a password?
  25. Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
  26. Is there any way to rename or hide wp-login.php?
  27. How to login with email only no username?
  28. How can I redirect user after entering wrong password?
  29. Increase of failed login attempts, brute force attacks? [closed]
  30. Login page ERROR: Cookies are blocked due to unexpected output
  31. How to programatically change username (user_login)?
  32. Separate registration and login for different roles
  33. SSO / authentication integration with external ‘directory service’
  34. Preventing session timeout
  35. How reduce wordpress login session timeout time?
  36. How to prefill WordPress registration with social details
  37. Check for correct username on custom login form
  38. Is there a is_user_logged_in() for multisite?
  39. Disallow user from editing their own profile information
  40. I can’t access my site via wp-admin
  41. ‘Password field is empty’ error when using autofill in Chrome
  42. Removing username from the ‘wordpress_logged_in’ cookie
  43. How to show ‘login error’ and ‘lost password’ on my template page?
  44. What is $interim_login?
  45. Custom login form
  46. How to prefill the username/password fields on the login page
  47. wp_signon returns user, but the user is not logged in
  48. How to restrict access to uploaded files?
  49. Adding extra authentication field in login page
  50. Replacing the WordPress password validation
  51. Prevent wp_login_form() from redirecting to wp-admin when there are errors
  52. Allowing users to edit only their page and nobody else’s
  53. Can an admin check passwords of registered users?
  54. Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
  55. wp_signon() does not authenticate user guidance needed
  56. What exactly is ReAuth?
  57. What are the differences between wp_users and wp_usermeta tables?
  58. WordPress auto login after registration not working
  59. Login members using web services
  60. Make my wordpress blog remember my login “forever”
  61. How to check in timber if user is loggedin?
  62. How do I change the language of only the login page?
  63. Disallowing Users of a Custom Role from Deleting or Adding Administrators?
  64. Disable WordPress 3.6 idle logout / login modal window / session expiration
  65. Stop WordPress from logging me out (need to keep me logged in)
  66. Woocommerce registration page [closed]
  67. How to disable autocomplete on the wp-login.php page
  68. Share login data/cookies between multiple installations
  69. Hide Admin Menu for Specific User ID who has administrator Role
  70. Synchronize WordPress user accounts across multiple domains and installations without using WordPress MU
  71. How to pass users back and forth using session data?
  72. How do I change the logo on the login page?
  73. Allow up to 5 Concurrent Login Sessions
  74. Why does WordPress hide the reset password key from the URL?
  75. Allowing an email as the username?
  76. How to use current_user_can()?
  77. Avoid to load default WP styles in login screen
  78. WordPress registration message
  79. How to fake a WordPress login?
  80. how to display the wordpress login and register forms on a page?
  81. Does wp_logout_url() destroy a session? (Logging out question)
  82. How can I send a welcome email to a user AFTER they login for the first time?
  83. Can not login with correct username and password
  84. Check if specific username is logged in
  85. How can i increase the login expiration length?
  86. How do I use add_action from a class method?
  87. How to remove the WordPress logo from login and register page?
  88. How can I add a custom script to footer of login page?
  89. Brute force attack?
  90. Customize wp_new_user_notification_email()
  91. Need to execute a cron job
  92. How to manually activate user in dashboard only by admin
  93. Login email after registration never sent or received
  94. Post list based on the user that is logged in
  95. How can I create a separate blog that is private?
  96. How to keep always logged in development environment
  97. Add Confirm Password field in wp-login.php Password Reset page
  98. Integrate recaptcha and wp_signon – what is needed?
  99. Stop users from logging in from multiple locations
  100. How do you add a custom option to user data?
Categories login Tags login, user-access, users
Add source URL from Feed WordPress (Syndication) plugin to a custom field in post editor
Script will not print in head if path to file is correct

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