You can try this:
/**
* Is the current user registred for more than x days ago?
*
* Based on the compare idea in this answer:
* http://stackoverflow.com/a/7130744/2078474
*
* @link http://wordpress.stackexchange.com/a/143597/26350
* @param int $reg_days_ago
* @return bool
*/
function is_user_reg_matured( $reg_days_ago = 30 )
{
$cu = wp_get_current_user();
return ( isset( $cu->data->user_registered ) && strtotime( $cu->data->user_registered ) < strtotime( sprintf( '-%d days', $reg_days_ago ) ) ) ? TRUE : FALSE;
}
This should return TRUE
for users registred more than x
days ago, and FALSE
for visitors (not logged in) and other users.
Usage Example:
if( is_user_reg_matured( 30 ) )
{
// show content
}
Shortcode:
You can for example add this as a shortcode:
[is_user_reg_matured reg_days_ago="30 ]
Content for register matured users only
[/is_user_reg_matured]
with:
add_shortcode( 'is_user_reg_matured', 'is_user_reg_matured_shortcode' );
/**
* Shortcode [is_user_reg_matured] to show content to register matured users only
*
* @link http://wordpress.stackexchange.com/a/143597/26350
* @param array $atts
* @param string $content
* @return string $content
*/
function is_user_reg_matured_shortcode( $atts = array(), $content="" )
{
$atts = shortcode_atts(
array(
'reg_days_ago' => '30',
), $atts, 'is_user_matured' );
if ( function_exists( 'is_user_reg_matured' ) )
if( is_user_reg_matured( (int) $atts['reg_days_ago'] ) )
return $content;
return '';
}