最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Find out when a user was created and display varied content depending on time since creation

programmeradmin0浏览0评论

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; ?>

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 asked Jan 31, 2011 at 4:01 RedRed 4233 gold badges9 silver badges15 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 6

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

The above code is now deprecated.

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

评论列表(0)

  1. 暂无评论