Problem:
Client wants to blacklist certain usernames on a User Form to register users.
Solution:
Server-side validation is required, such as with the following PHP code that should be added to the child theme's functions.php file:
add_filter( 'cred_form_validate', 'tssupp_validation', 10, 2 ); function tssupp_validation( $error_fields, $form_data ) { // split error_fields into fields and errors list( $fields,$errors ) = $error_fields; // apply to specific form if ( $form_data['id'] == 6590 ) { // disallow restricted names $restricted = array( 'admin', 'administrator', 'author' ); if ( isset( $fields['user_login']['value'] ) && in_array( $fields['user_login']['value'], $restricted ) ) { //set error message for my_field $errors['user_login'] = 'That username is restricted, please try another'; } } return array( $fields, $errors ); }
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
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)
Este tema contiene 6 respuestas, tiene 2 mensajes.
Última actualización por hace 6 años, 3 meses.
Asistido por: Nigel.