Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter pablow3v

    (@pablow3v)

    I got to put the mask in the form.

    But, where could i put a validation code to a new field? I tried in the “register.php” but I didn’t find where I can put the function to validate and send error menseger.

    Could you help me? Where could i put it?

    thank for all.
    Pablo

    Plugin Author Chad Butler

    (@cbutlerjr)

    Custom validation functions can be hooked to the wpmem_pre_register_data action and an error message can be set by putting it into the $wpmem_themsg global variable.

    http://rocketgeek.com/plugins/wp-members/users-guide/filter-hooks/wpmem_pre_register_data

    Thread Starter pablow3v

    (@pablow3v)

    I found it too.
    But I need to validate one specific field. I need to know when the “$fields” will be the field that i need validate. Like this:

    If ($fields == “field that i want”){

    validation code

    }

    To validate only this field “field that i want”.
    do I need use the ID of the “field that I want” ? But how can I use this information in the code ?

    $fields.id == “field-i-want-id” ?

    If you could help me in this problem I thank you.

    Sorry if it wasn’t so clean to understand and thanks for the helping and attention.
    Pablo.

    Plugin Author Chad Butler

    (@cbutlerjr)

    $fields is an array of the form data. The array is keyed by meta key (which is the field’s option name in the plugin’s fields tab).

    So your validation would be:

    if ( $fields['field_meta_key'] == 'field value' ) { ...

    declare the $wpmem_themsg global variable for giving it an error message value if the field does not validate.

    global $wpmem_themsg;
    if ( $fields['my_field'] != 'some value' ) {
        $wpmem_themsg = 'Sorry, you did not enter an acceptable value.';
    }
    Thread Starter pablow3v

    (@pablow3v)

    It work! Thanks very much.

    Good luck with your plugins and projects and thanks again for the support and attention.

    Pablo.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Put mask and other validation in the field’ is closed to new replies.