Skip Navigation

[Resolved] Formatting the output of user_registered shortcode

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: 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

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"]
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.