"Member Since" Shortcode
Adds a [wpide_member_since] shortcode that shows the date the logged-in member joined, or how long ago, for welcome messages and account pages.
Opens WPIDE on
Code
add_shortcode( 'wpide_member_since', function ( $atts ) {
$atts = shortcode_atts( array( 'format' => '' ), $atts, 'wpide_member_since' );
if ( ! is_user_logged_in() ) {
return '';
}
$joined = strtotime( wp_get_current_user()->user_registered . ' UTC' );
if ( 'relative' === $atts['format'] ) {
return esc_html( human_time_diff( $joined ) );
}
return esc_html( wp_date( $atts['format'] ? $atts['format'] : get_option( 'date_format' ), $joined ) );
} );
Notes
Use [wpide_member_since format="relative"] for "3 months", or any PHP date format such as format="F Y".
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.