• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Plugins » WP-Members » Documentation » Filter Hooks » wpmem_register_form_rows

wpmem_register_form_rows

Description

Filters the form rows before they are put together for the form.

Parameters

$rows
(array) (required) An array of the forms row elements.  Each row element will include the following keys:

  • order – the field order (currently not used)
  • label_text – the raw text for the label (static)
  • type – The field type (i.e. text, checkbox, dropdown, textarea)
  • value – The field value (only populated if error state or profile edit)
  • values – The possible values for the field (dropdown select, multiple select/checkbox, radio group) – 3.1 and higher only
  • row_before – HTML tags before the row
  • label – HTML label tag
  • field_before – HTML tags before the field input tag
  • field – HTML input
  • field_after – HTML tags after the field input tag
  • row_after = HTML tags after the row

$tag
(string) (optional) Indicates the form that is being displayed (new|edit).

Usage

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://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()

Notes

  • When using wpmem_register_form_rows to generate new field or label HTML, the following API functions can be used:
    wpmem_form_label()
    wpmem_form_field()
  • New array values can be inserted using wpmem_array_insert()

Changelog

Introduced in version 2.9.0
Added “label_text” key in 3.0.9
Added “values” key in 3.1.0
Deprecated “order” key in 3.1.2

Source

wpmem_register_form_rows is located in includes/class-wp-members-forms.php

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
  • Using a code snippets plugin
  • 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.

  • Getting Started
  • Recommended WordPress® Settings
  • Plugin Settings
    • Options
    • Fields
    • Dialogs
    • Emails
    • New Feature Settings
  • Managing Content
    • Restricting Posts
    • Restricting Pages
    • Show Excerpts
    • Custom Post Types
  • Managing Users
    • Import Users
    • Export Users
    • Edit Users
    • Search Users
  • Login
  • Registration
    • Choosing Fields
    • Create a Registration Page
    • Moderating Registration
    • Using CAPTCHA
    • Removing Registration Options
  • User Profile
  • Memberships
    • Membership Properties
    • Membership Levels
  • Menus
    • Individual Menu Items
    • Logged In Menus
    • Login/Logout Menu Link
  • Customizing Emails
    • Email Address
    • Email Content
    • Email Format
    • Email Shortcodes
    • Email Troubleshooting
  • Customizing Forms
    • Create a Custom Stylesheet
    • Using the WordPress Customizer
    • Login Form HTML
    • Registration Form HTML
    • Widget Login Form HTML
  • Translation and Localization
    • Maintain a custom translation file
    • Filter untranslated strings
    • Multi-language Considerations
  • Shortcodes
    • Pages and Forms
    • Login Status
    • User Fields
    • Memberships
    • Email
    • Other Shortcodes
  • WP-CLI Commands
  • API Functions
  • Filter Hooks
  • Action Hooks
  • FAQs
    • Email troubleshooting
    • Passwords are not being included in Emails
    • The plugin isn’t blocking my content
    • Are files protected?
    • How can I prevent registration spam?
    • How to add a shortcode
    • How to apply login redirects
    • Why can’t users log in?
    • Why does reCAPTCHA v3 fail?
    • Troubleshooting Really Simple Captcha
    • Why do I get a 403 error?
    • How do I use code snippets?
    • My changes aren’t showing up
    • How to hide the “Admin Bar”
    • How to add a forgot password link
    • Password reset doesn’t show any fields
    • Domain not included in the password reset link
    • There was an error processing the form
    • Hidden vs. Restricted
  • Demo Videos
  • How to Request Support
  • Copy Settings for Support
  • Hosting Recommendations

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy