Description
This filter allows you to make changes to the registration and user profile form fields. The filter passes an array keyed by the field meta keys where each key contains an array of settings for the individual field.
The wpmem_inc_registration function uses the wp_parse_args function to merge arguments passed through this filter with the following defaults:
$examples = array( 'text_field' => array( 'label' => 'The Field Label', 'type' => 'text', // text|email|url|password/textarea 'register' => 1, // boolean to display in form or use admin only 'required' => 1, // boolean to make field required 'profile' => '', // for future use 'native' => 1, // boolean is the field a native WP field? ), 'checkbox_field' => array( 'label' => 'The Field Label', 'type' => 'checkbox', 'register' => 1, // same as text field 'required' => 1, // same as text field 'profile' => '', // same as text field 'native' => 1, // same as text field 'checked_value' => 'yes', // The field value if checked. 'checked_default' => 1, // boolean is the field checked by default. ), 'multiple_checkbox' => array( 'label' => 'The Field Label', 'type' => 'mutlicheck', // multicheck, dropdown, multiselect, radio 'register' => 1, // same as text field 'required' => 1, // same as text field 'profile' => '', // same as text field 'native' => 1, // same as text field 'values' => array ( [0] => 'Choice One|choice_one', [1] => '1,000|one_thousand', [2] => '1,000-10,000|1,000-10,000', [3] => 'Last Row|last_row', ), 'delimiter' => '|', // stored data delimiter, can be "|" or "," not used for radio group 'options' => array( 'choice_one' => 'Choice One', 'one_thousand' => '1,000', '1,000-10,000' => '1,000-10,000', 'last_row' => 'Last Row', ), ), 'file_field' => array( 'label' => 'The Field Label', 'type' => 'file', // file|image 'register' => 1, // same as text field 'required' => 1, // same as text field 'profile' => '', // same as text field 'native' => 1, // same as text field 'file_types' => 'doc|pdf|gif|jpg|png|etc', ), 'hidden_field' => array( 'label' => 'The Field Label', 'type' => 'hidden', 'register' => 1, // same as text field 'required' => 1, // same as text field 'profile' => '', // same as text field 'native' => 1, // same as text field 'value' => 'the field value', ), );
Parameters
$arr
(array) (required) An array of fields for the form.
$tag
(string) (optional) Indicates the form that is being displayed (new|edit).
Notes
Each defined field from the Fields tab will be in the array, keyed using the field’s meta key. At each meta key will be an array with the necessary settings for the field type. All field types need ‘label’, ‘type’, ‘register’, ‘required’, ‘profile’, and ‘native’.
There are basically five possible array configurations:
- text, email, url, password, and textarea fields
- checkbox fields
- mutiple checkbox, select (dropdown), multiple select, and radio group fields
- file and image fields
- hidden fields
You can make custom fields on the fly with this filter, but you will also need to make sure any data is handled through the various actions (such as wpmem_post_register_data).
Changelog
Introduced in version 2.9.0
Source
wpmem_register_fields_arr is located in inc/forms.php
Usage
add_filter( 'wpmem_register_fields_arr', 'my_register_form_fields', 10, 2 ); function my_register_form_fields( $arr, $tag ) { if ( 'new' == $tag ) { /* * If this is new registration (not user profile), * add "My Custom Field". */ $arr['my_custom_field'] = array( 'label' => "My Custom Field", 'type' => 'text', 'register' => 1, 'required' => 0, 'profile' => 0, 'native' => 0, ); } return $arr; }