Description
This filter hook allows you to filter the form data that is posted in the registration form prior to the plugin’s own validation process.
Common uses of this filter would be cases where you need to make some changes to the data before it is validated by the plugin’s validation. For example, if you are filtering out the username field in favor of using the email as a username, you still need to pass a value for username (which would be the email). This filter hook would allow you to filter the fields to include the email address as both the email address and the username so that default form validation does not fail.
Keep in mind the following:
- You MUST make sure that your filter function returns the array of fields.
- Your filtered array will need to be able to pass the plugin’s default form validation. This means it needs to have a valid and unique username, valid and unique email address, and contain data for any of the fields that are marked as required in the plugin’s fields manager. If for some reason the data will go outside of this requirement, you still need to pass valid data here and you can change it before the user is actually registered by filtering it with wpmem_register_data.
Parameters
$fields
(array)(required) An array of the posted form data, keyed by the field meta keys.
$tag
(string)(optional) The process being run – either “register” or “update”
Usage
add_filter( 'wpmem_pre_validate_form', 'my_pre_validation_filter', 10, 2 ); function my_pre_validation_filter( $fields, $tag ) { /** * The data from the registration form is brought in * with the $fields array. You can filter any of the * the values, and add/subtract from the array before * returning the filtered result. */ return $fields; }
Changelog
- Introduced in 2.8.2
- $tag argument added in 3.1.7
Source
wpmem_pre_validate_form is located in includes/class-wp-members-user.php