Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking to display different content after a user registers. Is there a way to find out the registration date and then if it's been 1 day display one thing, but if it's been 2 days display something else?

Something like this, but based on the registration date and not a post entry date:

<?php if (strtotime($post->post_date) > strtotime('-30 days')): ?>
   //Text for posts created in the last 30 days
<?php endif; ?>
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Yes you can!

<?php 
get_currentuserinfo(); 
$user_data = get_userdata($user_ID);
$registered_date = $user_data->user_registered;
if (strtotime($registered_date) > strtotime('-30 days')){
   //Text for users registered in the last 30 days
}
?>

hope this helps

share|improve this answer
    
Thanks for the help but I am getting this error now: Fatal error: Cannot use object of type stdClass as array –  Red Jan 31 '11 at 17:44
    
my bad, i updated the code, its $user_data->user_registered instead of $user_data['user_registered'], if not then paste your code here so we could see –  Bainternet Jan 31 '11 at 17:59
    
Thanks for the quick response. I have simply pasted this code into a wordpress template, so no additional code to share and I am now getting this error:Parse error: syntax error, unexpected –  Red Jan 31 '11 at 18:09
    
ok weird, try the posted answer now and id not please post your code –  Bainternet Jan 31 '11 at 18:22
    
Ok, figured it out. I edited the code above. It was missing a ending ) after $registered_date –  Red Jan 31 '11 at 18:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.