Advertisement
eventsmanager

Custom add verify email address field on booking form

Jul 11th, 2024
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2.  
  3. //This set of snippets adds a secondary email field so that the user must provide matching values in each field, to help prevent user typos.
  4. function my_emp_email_validation_output( $content, $EM_Form, $field ){
  5. if( !is_user_logged_in() && $field['type'] == 'user_email' ){
  6. $label = 'Confirm '. $field['label']; //change this to alter label of second field
  7. $content .= str_replace($field['label'], $label, str_replace($field['fieldid'],$field['fieldid'].'_2', $content));
  8. }
  9. return $content;
  10. }
  11. add_filter('emp_forms_output_field', 'my_emp_email_validation_output', 10, 3);
  12.  
  13. function my_emp_email_validation( $result, $field, $value, $EM_Form ){
  14. if( !is_user_logged_in() && $field['type'] == 'user_email' && $result ){
  15. if( $value != $_REQUEST[$field['fieldid'].'_2'] ){
  16. //modify this next line for a different error message
  17. $EM_Form->add_error( 'Emails do not match, please confirm your email below.' );
  18. }
  19. }
  20. return $result;
  21. }
  22. add_filter('emp_form_validate_field', 'my_emp_email_validation', 10, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement