CM Product Directory Community (CMPDC) - Changing the view with filters (advanced)
CM Product Directory Community
Disclaimer: This tutorial requires PHP modification skills.
It's possible to change the default ways displayed in the Community form with the " cmpdc_form_data" filter.
This new way allows to group the fields in the sections, decide about their type, labels and whether or not they're mandatory.
add_filter( 'cmpdc_form_data', array( __CLASS__, 'getBasicFormData' ) );
In the example function below we've added a section of fields under the fieldMap key of the array.
The structure required to add the fields is the following multi-level array:
- top level array key is the label of the Section
- top level value is the array with the following keys:
- id - the id of the section (helpful for the styling)
- fields - the array of arrays each describing one field:
- field array consists of the following keys:
- name - name of the data, it will be stored in the meta under this key
- type - type of the rendered field, possible values are: text, date, textarea, select, confirm, checkbox, taxonomy
- placeholder - the placeholder value for the input
- mandatory - the field allowing to decide if it's required field (Y) or not (N)
- value - the default value of the field
- options - the array of key - value pairs eg. array( 'apple' => 'Apple') will display the Apple and the inputed value would be 'apple'
- taxonomy - the slug of the taxonomy to display (only for 'taxonomy' type)
- field array consists of the following keys:
public static function getBasicFormData( $data = array() ) { /** * For testing purposes */ $data[ 'fieldMap' ] = array( '1 - User Details' => array( 'id' => 'user_details', 'fields' => array( array( 'name' => 'cmbd_username', 'type' => 'text', 'placeholder' => 'Username', 'mandatory' => 'Y' ), array( 'name' => 'cmbd_email', 'type' => 'text', 'placeholder' => 'E-mail', 'mandatory' => 'Y', 'value' => '' ), ) ) ); return $data; }
After these fields are added to the form they will overwrite the default product fields!
More information about the CM Business Directory Community WordPress Plugin Other WordPress products can be found at CreativeMinds WordPress Store |
|
Let us know how we can Improve this Product Documentation Page To open a Support Ticket visit our support center |