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

Retrieve duration since sign up

WordPress doesn’t have a “Duration Since Signup” value so you’ll need to calculate it by finding the difference between the user registration date and the current date. I suggest getting the user above the conditional:

function set_mail_html_content_type() {
    return 'text/html';
}

add_action( 'user_help_signup', 10 ,2 );
function user_help_signup( $ID, //DURATION SINCE SIGN UP ) {
    $curr_user  = get_user_by( 'id', $post->post_author );
    $reg_date   = new DateTime( $curr_user->user_registered );
    $curr_date  = new DateTime();
    $days_reg   = intval( $curr_date->diff( $reg_date )->format( "%a" ) );

    if ( $days_reg > 3 || count_user_posts( $post->post_author ) > 1 ) {
        return;
    }

    $to      = $curr_user->user_email;
    $subject="Need help ?";
    $headers = array('Content-Type: text/html');
    $message="<h3>Hi {display_name}! </h3> <p>

    You signed up 3 days ago on mysite.com and we wanted to know if we could help you to get started ";

    wp_mail( $to, $subject, $message, 'Content-Type: text/html' ); 
}

We know that $curr_user->user_registered holds the date that the user registered and DateTime() will get the current date so we can use the built-in DateTime method diff() to get the difference and put it in as day format as %r%a. There’s a good StackOverflow Answer on getting the day difference between two dates.

Related Posts:

  1. Mailing list sign up form without plugin
  2. SMTP connect() failed PHPmailer – PHP
  3. What is the difference between ports 465 and 587?
  4. Email validation in Ruby on Rails?
  5. Is there a way to embed an iframe in an email with text that updates?
  6. Sending multipart (text/html) emails via wp_mail() will likely get your domain banned
  7. How to set SMTP programmatically
  8. changing notification emails from WordPress @mydomain.net to something else
  9. Disable user registration password email
  10. Alert Email when any Post or Page is Changed
  11. Do something after sending email
  12. How do I customise the new user welcome email
  13. How do you update user_email on the front end in WP 3.3?
  14. Missing URL in password reset email
  15. User Without Email?
  16. “Reply-to Address” Email
  17. prevent users from changing their email address
  18. Disable new user notification to admin email
  19. Allow Duplicate Email Address for Different Users
  20. Email confirmation on registration
  21. Customizing lost password email
  22. Create custom welcome email without a plugin
  23. Include HTML template file in wp_mail
  24. Email sent from WordPress has HTML tags
  25. How to disable automated E-Mail on PHP error/exception?
  26. Reset Password – change from name and email address
  27. How do i send mail with custom Form Data using WordPress
  28. Email as Username in registration
  29. Email stats at Ma.tt contact form
  30. Fwd: [Website Name] Notice of Email Change [closed]
  31. Send all WPMU emails via SMTP
  32. Send mail to wordpress admin
  33. Send a confirmation of user role upgrade conditionally
  34. WP Cron emails not working
  35. Dynamically send pdf attached to post with contact form 7 [closed]
  36. Few chars getting replaced with ‘=’ in mail content in wp_mail()
  37. Locked out of my own blog and password reset not working
  38. wp_mail recipient array not sending?
  39. Change Password notification text on mail
  40. Need to manually regsiter user, send the password and retreive their user ID
  41. Transferring contact form input to an email account without using an email-proxy
  42. Should I use the standard wp_mail() function for a premium theme?
  43. wpmu_signup_user_notification filter not working
  44. On form submission how to send 2 email to different users
  45. How to Configure SMTP on wordpress Cant Send Email
  46. email wordpress users using BCC
  47. Contact Form 7 + Configure SMTP: Sender email appearing as my own email [closed]
  48. email sends from [email protected] even though I have it set to something else
  49. How to add line breaks to $email[‘body’] when using auto_core_update_email hook
  50. Handle registrations in WordPress when user doesn’t have any email?
  51. Joining confirmation email
  52. How to sent one form values to 2 different sites in wordpress
  53. How to setup SMTP for only one specific wp_mail()
  54. apostrophe in email name
  55. Sanitizing and validating email field
  56. Disable WP notifications for commenting on own posts
  57. General Setting Allow Multiple Email Notification
  58. Must I change the admin user email address while changing the general email address?
  59. User invite email not delivered – related to subdomain?
  60. Can I configure WordPress to use postfix without a plugin?
  61. Ability to download only after email supplied [closed]
  62. Batch Emails with wp_mail()
  63. Email notification after registration in WordPress
  64. Subscribe from another website to the same list [closed]
  65. Obfuscating Email Addresses in Form Fields
  66. Email ‘from address’ has a www in it
  67. How to validate website field in contact form 7?
  68. How to Change WooCommerce new order email?
  69. Trigger WordPress Actions from Email?
  70. WordPress E-mail Config
  71. Is there no way to send email using SMTP without plugin or custom coding?
  72. How to change WordPress email notification sender?
  73. Contact form sender email
  74. PHP mail() works but wp_mail() does not
  75. Send email daily from WordPress site
  76. WordPress Add New User – Send an Activation Email
  77. Send email only upon draft
  78. Mechanism to send to users of secured WordPress install new notifications by SMS or email?
  79. How to change the Customer new account email
  80. Sending emptys emails every day, How stop it?
  81. wordpress do not let user registered with info@ email and other reserved emails to get registered by users
  82. Emails marked as spam because it’s contain via box4231.bluehost.com
  83. How to change the text of automatic E-Mails e.g. after changing your password? (German localization)
  84. Is it possible to change an existing post status from ‘pending’ to ‘publish’ via email?
  85. WP mail sent to MS Exchange recipients = occasional email corruption?
  86. WordPress email reply back to the original post author
  87. Limit number of emails per second
  88. What can be wrong when automated backups stop being sent to email?
  89. Wp_new_user_notification doesn’t work
  90. WordPress reset password email is not working – woocommerce and checkmail does work
  91. How to set custom from email address in wp
  92. How do I make WordPress send an email to the user when his account gets approved (manual by me)
  93. Throttling email frequency
  94. Make WordPress use timezone for email Date header
  95. How to send mail from WordPress if one server hosts page and another email?
  96. User registration email and let user choose pasword
  97. How to translate WordPress Emails?
  98. WordPress unable to send mail
  99. Correctly configure SPF/DMARC record to work with WordPress [closed]
  100. Share pdf with a friend via email [closed]
Categories email Tags email, signup
.htaccess Non-‘www’ to ‘www’ Subdomain Redirection Only Works for Homepage
Insert widgets into loop/custom query at every nth position

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