Skip Navigation

[Resolved] Formatting the output of user_registered shortcode

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 3 years ago.

Assigned support staff: Christian Cox.

Author
Posts
#571396

I am using the user_registered attribute to show the date that the user was registered, but I cant chage the way the date is displayed.
It´s always something like "2017-09-18 18:10:44". I wanted it to be 18-09-2017 or 18/09/2017.
How can it be done?

Thanks for your help.

#571521

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Types doesn't offer the ability to customize the format of that date, but you can use a custom shortcode to format it however you'd like. Add the following code to functions.php:

add_shortcode( 'format_reg_date', 'format_reg_date_func');
function format_reg_date_func($atts)
{
  $user_id = $atts['userid'];
  $format = $atts['format'];
  $reg_date = date($format, strtotime(get_userdata($user_id)->user_registered));
  return $reg_date;
}

Then you can use the shortcode like so:

[format_reg_date userid="[wpv-user field='ID']" format="m/d/Y"]