admin管理员组文章数量:1425921
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
2 Answers
Reset to default 6Yes 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
}
?>
本文标签: Find out when a user was created and display varied content depending on time since creation
版权声明:本文标题:Find out when a user was created and display varied content depending on time since creation 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745456067a2659106.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论