Problem: I would like to make the first_name and last_name fields required in a User (CRED) Form, and I would like to make the error message translatable. The code I have doesn't seem to be working.
Solution:
add_filter('cred_filter_field_before_add_to_form', 'required_user_fields_func', 10, 2); function required_user_fields_func($field, $computed_values){ if(in_array($field['id'], array('first_name', 'last_name'))){ $field['data'] = is_array($field['data']) ? $field['data'] : array(); $field['data']['validate']['required'] = array ( 'active' => 1, 'value' => 1, 'message' => __('This field is required', 'your-theme-context'); ); } return $field; }
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 5 replies, has 2 voices.
Last updated by 6 years, 5 months ago.
Assisted by: Christian Cox.