Skip Navigation

[Resolved] Capitalize Custom User Field value in Fields and Text Block

This support ticket is created 3 years, 5 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 3 voices.

Last updated by Luo Yang 3 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1821609

Hello, can you tell me how to capitalize the first letter of a user's submitted field value when showing it in a Toolset Fields and Text Block (Gutenberg)?

I created a Toolset custom user field: 1-1-new-first-name (single line text field)

I placed this field inside a Toolset user form: 1-1-new-name-form

If the user submits the name Emily, then all is well. But...

(1) Let's say that the user instead submits the name: emily

I'm using a Toolset Fields and Text block to show the value that the user submitted. For example:
"Thank you, you have submitted your new name as emily."

But is there a way to instead show this value as Emily?

(2) As the above field is a single line text field, it is possible for the user to submit a multiple word name such as: mary ellen

Is there a way to capitalize both of these words so that when I display the values of the field, the user sees the correction?
"Thank you, you have submitted your new name as Mary Ellen."

Thank you!

#1822187

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

You have two options.

The first would be to add the name inside a span with some class name you can target with CSS, and then use text-transform: capitalize to ensure the name(s) are displayed with capital initial letters.

See hidden link

The second requires some coding, where you register a custom shortcode that uses the PHP function ucwords to transform the string before it is printed.

See hidden link and https://developer.wordpress.org/plugins/shortcodes/

#1825333

Thanks, I tried the first solution and it works. The only problem is that I'm using Gutenberg blocks, and I have to convert a block to HTML before adding the span around the Toolset field.

Is there a way I can instead prompt the user to enter a capitalized word if they have not, right after they submit the Toolset form? I don't know if this would be a "validation rule" or not, as some names may have small caps such as "de Gaulle" so I don't want to force it, just to prompt if they've entered a name without caps.

#1825597

Hello,

There isn't such kind of built-in feature within Toolset, you might consider custom JS codes, for example, after user fill value into the field "1-1-new-first-name", trigger a JS function, check if the first letter of words is upper case
hidden link

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.