Custom Fields
Re-Envisioned
Support MB User Profile Backend validation for registration form

This topic contains 1 reply, has 1 voice, and was last updated by  Harold 8 months, 1 week ago.

  • Creator
    Topic
  • #11040

    Harold
    Participant

    Hi,

    I need to do some backend validation on the custom fields of the registration form. For example, i’d like to check if the invitation code during registration is correct, and if not prevent registration of a new user and echo “Incorrect invitation code” on the registration form. I tried different things with the “rwmb_profile_validate” hook, but it didn’t work.

    https://ghostbin.com/paste/5oh7p

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #11049

    Harold
    Participant

    This is the code so far. How do I echo a warning if the invitation code from the registration form is incorrect?

    
    // Validation for metabox registration form
    add_filter( 'rwmb_profile_validate', function( $is_valid, $config ) {
        if ( 'invitation_verification' === $config['id'] ) {
            if ( '123' !== $_POST['invitation_code'] ) {
                // do NOT register new user and echo "Incorrect invitation code" on the registration form
            }
        }
        return $is_valid;
    }, 10, 2 );
    
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.