if test on wp user registration date

Posted on 2012-09-09
Last Modified: 2012-09-09
I need to test to see if a wordpress user registered more than 2 months ago.

I can get the registration date using this:

$user_reg_dt = get_the_author_meta('user_registered');

if I echo $user_reg_dt I find the date is displayed like this: 2011-09-01 21:53:31

Now, I need to do this:

if ($user_reg_dt > (two months ago) ) { /* do this */ }

Can you show me how to write the (two months ago) part to make this work?


Question by:St_Aug_Beach_Bum
    LVL 10

    Accepted Solution

    if   ( strtotime ( "now" ) -  strtotime ($user_reg_dt)   >60*60*24*60   )   { do something }

    last 60  means 60 days , it could be 61 or 62

    to make the script run a bit faster you can use 5184000  instead of   60*60*24*60
    but i like to use   60*60*24*60

    Author Comment

    Working great - thank you!!!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
    In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now