Skip to content

Instantly share code, notes, and snippets.

@alessandrotesoro
Created February 2, 2016 13:45
Show Gist options
  • Select an option

  • Save alessandrotesoro/be18855eddde18a43f81 to your computer and use it in GitHub Desktop.

Select an option

Save alessandrotesoro/be18855eddde18a43f81 to your computer and use it in GitHub Desktop.

Revisions

  1. alessandrotesoro created this gist Feb 2, 2016.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    function wpum_add_new_email_field( $fields ) {

    $fields[ 'confirm_email' ] = array(
    'label' => 'Confirm Email',
    'type' => 'email',
    'meta' => 'email_confirmation',
    'required' => true,
    'description' => 'Add something here if needed',
    );

    return $fields;

    }
    add_filter( 'wpum_get_registration_fields', 'wpum_add_new_email_field' );

    function wpum_verify_email_confirmation( $passed, $fields, $values ) {

    $first_email = $values['register'][ 'user_email' ];
    $confirm_email = $values['register'][ 'confirm_email' ];

    if( $first_email !== $confirm_email ) {
    return new WP_Error( 'email-validation-error', 'Email mismatch' );
    }

    return $passed;

    }
    add_filter( 'wpum/form/validate=register', 'wpum_verify_email_confirmation', 10, 3 );