Problem:
Automatically capitalise the first letter of a custom field submitted with a Toolset Form.
Solution:
You can use the cred_save_data hook to manipulate the field value—capitalising the first letter—with some custom code, like so:
function tssupp_capitalise_field( $post_id, $form_data ){ if ( in_array( $form_data['id'], array( 98, 216 ) ) ) { // Edit form IDs $slug = 'some-field'; // Edit field slug $field = get_post_meta( $post_id, 'wpcf-' . $slug, true ); $field = ucfirst($field); update_post_meta( $post_id, 'wpcf-' . $slug, $field ); } } add_action( 'cred_save_data', 'tssupp_capitalise_field', 10, 2 );
Relevant Documentation:
https://toolset.com/documentation/adding-custom-code/
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 |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 5 months ago.
Assisted by: Nigel.