Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    Good effort – clearly you spent some time looking at either the documentation or the inline documentation.

    wpmem_pre_validate_form isn’t really for validating data – it’s a filter if something needs to be changed prior to validation. For example, if you were going to store a full_name field that is made of the user’s first and last name you could use this filter to combine first and last name.

    If you need to do custom form field validation you should use the wpmem_pre_register_data action. The documentation for the action hook describes how to set a custom error message.

    Keep in mind, this is really only necessary for things that are more complex that the basic. If the field is text, textarea, checkbox, or dropdown, you can just add it through the field’s form tab and if it is a required field, it will be checked for a value.

    Thread Starter karlosdpm

    (@karlosdpm)

    Hello,

    I am implementing a field that is the national ID document of Spain. Since not 2 people can have the same ID, if the ID is already on file in the db, it will throw an error and not let the registration proceed. It also has a special format 8(number) + 1(letter).

    That is the special field I need to have.

    Am I on the right path?

    Thank you!

    Plugin Author Chad Butler

    (@cbutlerjr)

    I would say that in this case, you want to just include the field using the plugin’s fields tab (add a new field is below the table of fields).

    If it is required, set it as required here. But you don’t need to have that for your custom validation.

    Then use the wpmem_pre_register_data action hook I mentioned. Here you can validate the field and if it does not meet validation requirements, you can set an error message.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Set error message for custom registration field’ is closed to new replies.