add_filter( 'wpmem_register_form_rows', 'my_register_form_rows_filter', 10, 2 ); function my_register_form_rows_filter( $rows, $toggle ) { /* Form rows are assembled as an array and the entire array is passed through this filter. Each row will have an array key equal to its optionname (meta_key). order, label_type, type, value, and values are all passed for doing value comparisons. The remaining keys are form output and changes here will be reflected in the displayed form. $rows['meta_key'] = array ( 'order' => 1, 'type' => 'text', 'value' => '', 'row_before' => '', 'label' => '<label for="option_name" class="text">Field Label</label>', 'field_before' => '<div class="div_text">', 'field' => '<input name="option_name" type="text" id="option_name" value="" class="textbox" />', 'field_after' => '</div>', 'row_after' => '', ); $rows['meta_key']['label'] can be generated with wpmem_form_label() $rows['meta_key']['field'] can be generated with wpmem_form_field() */ return $rows; } /* * The following example changes an element's output. */ add_filter( 'wpmem_register_form_rows', 'my_new_element', 10, 2 ); function my_new_element( $rows, $tag ) { // Change the label for a field with "my_field" as the meta key $rows['my_field']['label'] = "<label>My Custom Field Label</label>"; return $rows; } /* * The following example adds a div wrapper with the * class "my_row_wrapper" to all form rows. */ add_filter( 'wpmem_register_form_rows', 'my_row_wrapper', 10, 2 ); function my_row_wrapper( $rows, $tag ) { foreach ( $rows as $meta_key => $row ) { $rows[ $meta_key ]['row_before'] = '<div class="my_row_wrapper">'; $rows[ $meta_key ]['row_after'] = '</div>'; } return $rows; } /* * The following example adds a "heading" row between the name * fields and the address fields. This is just a single example * of how wpmem_register_form_rows can be used to put additional * rows into the form (note: it can also be used to remove rows). * * This example also uses wpmem_array_insert(). * @see: https://test.rocketgeek.com/plugins/wp-members/docs/api-functions/wpmem_array_insert/ */ add_filter( 'wpmem_register_form_rows', 'my_field_separator', 10, 2 ); function my_field_separator( $rows, $tag ) { /* * Define an array of row elements. * Unused elements can be empty ('') * but must still be defined. */ $new_row['address_heading'] = array( 'order' => '', 'meta' => '', 'type' => '', 'value' => '', 'row_before' => '', 'label' => '<label class="text"></label>', 'field_before' => '<div class="div_text">', 'field' => '<h3>Please include your address information</h3>', 'field_after' => '</div>', 'row_after' => '' ); /* * Add your new row into the $rows array using * wpmem_array_insert( $array, $new, $key ) * - $array The array you are adding to. * - $new The new element being added. * - $key The key in $array you will add after. */ $rows = wpmem_array_insert( $rows, $new_row, 'last_name' ); // If additional rows are needed, repeat the process. // Return filtered $rows array. return $rows; } // end of my_field_separator()
Not sure what to do with this code?
You're not a "coder" and don't know what to do? Don't worry! Code Snippets are the basic building blocks of WordPress customization, and once you know the basics, they are simple to use.
Here are some free articles to get you started:
- Using Code Snippets from the Site
- The functions.php File
- Create a plugin file for custom functions
- Create a child theme
- Do not modify plugin files!
For "hands on" help, consider a plugin support subscription or the Pro Bundle.