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. In Django, how do I know the currently logged-in user?
  23. Disallow user from editing their own profile information
  24. What exactly is ReAuth?
  25. What are the differences between wp_users and wp_usermeta tables?
  26. How can I send a welcome email to a user AFTER they login for the first time?
  27. Can not login with correct username and password
  28. Post list based on the user that is logged in
  29. Stop users from logging in from multiple locations
  30. Why does is_user_logged_in() return false after redirect from another site?
  31. My login form does not work
  32. Copy a user from one WordPress site to another
  33. Get user info outside WordPress
  34. Cookie settings for session across WPML subdomains using custom AJAX login
  35. Is there a way to remove wp-login.php alias (login)?
  36. How do I create a specific login page for a specific user?
  37. wp-admin redirecting to wp-login.php
  38. Check for user meta data at Login
  39. Restrict PDF links
  40. Remote REST request to check login status
  41. How can I test the login for an expired session?
  42. Force user to login in home page
  43. Last time a user logged in
  44. Login as a client no dashboard menu?
  45. Allow access to a page for admins only
  46. Customizing the WordPress login form
  47. How to display username and password after registration
  48. wp-login gives 404 error, but wp-admin is working fine
  49. Custom login message for single post pages only
  50. Private page protected with username and password
  51. Restrict users post for himself
  52. Password reset – Disabled for LDAP accounts
  53. Completely replacing the login form
  54. When I try to login in wordpress it is showing “USER Doesn’t Exists”
  55. Displaying different in-page content to cliente/admin
  56. Single sign on with custom site
  57. By registering always make uppercase the first letter of the login
  58. Best option to implement external register/login to WP from self-made API
  59. Enqueue new login style sheet
  60. WordPress Conditional Login Links
  61. Do more action after login successfully
  62. I cannot login and am getting this error message. .
  63. Allow admins to login as other users
  64. Cannot log into migrated site
  65. WordPress SSL not working [closed]
  66. How to unpublish my new site while working on it?
  67. How to force “remember me” users to login again?
  68. User not able to sign in after wp_authenticate() and wp_signon() wordpress
  69. WordPress site login Redirect
  70. Thank You Page Layout Differs on User Logged In Status
  71. On Homepage “is_user_logged_in()” function is not working after login and it is working after refresh the page?
  72. Problem in auto login after registration
  73. Cant reset password my wordpress password not even with phpMyAdmin
  74. Get WordPress logged in username from root domain when WP is installed in a subfolder
  75. wp-cron event doesn’t run when custom login API is enabled
  76. Does it make sense to check a nonce on user log in?
  77. restrict admin panel sections to users
  78. Multisite – site user limited only for this site
  79. $user_login is not working if author has only 1 post
  80. Building a custom login form – encountering issues
  81. Site login failed due to strange warning
  82. Chosen user password in registration is not being accepted on Login
  83. Allowing users to edit only their page and nobody else’s
  84. How to bulk change user role to “No role for this site”
  85. loging to Admin page not working at all
  86. WordPress Cookies – wp_set_auth_cookie
  87. Authenticate return value
  88. Current User Seeing Another Logged In User Info
  89. Front-end login problem: requires re-authorization when accessing dashboard
  90. When trying to login if already logged in, form just shakes – error message remains empty
  91. Handle POST request sent from an external site for login?
  92. Unable to login after adding ReCaptacha without API key
  93. Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
  94. How to create an alternative login page that does not use any plugins?
  95. user can login from single account detail from multiple locations(computer) at the same time [closed]
  96. Cant edit profile from frontend
  97. Login and register by API
  98. Log in a user upon password reset?
  99. How to remove/limit Editor accounts privileges, to prevent them from deleting media and pages created by Admin
  100. index.php file shown when trying to load wesite
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
  • 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