Support » Plugin: WP-Members Membership Plugin » Pass variable to ‘value’ in registration form

  • 306digital



    I have a variable in $_GET in my page URL that I want to pass as the default value in my registration form.

    I’ve tried the code below but it does not work. Can someone help,

    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['user_email']['value'] = $_GET['email'];
        return $rows;
Viewing 1 replies (of 1 total)
  • Plugin Author Chad Butler


    The “value” in the array is primarily so that in the filter you know what the value of that particular field is. This is helpful if you are going to rebuild the input HTML (which would be the case here). So you’re close – you’re just changing the wrong thing in the filter. You need to change the “field” value.

    Something like this:

    $rows['user_email']['field'] = '<input type="text" value="' . $_GET['email'] . '" />';

    Also, don’t forget to sanitize your input from $_GET. Use sanitize_email() for that before you use it:

    You should also validate it with is_email() (

    I’d probably do it like the following, sanitizing the value, validating that it is in fact an email and if it’s not, empty the value:

    $email = sanitize_email( $_GET['email'] );
    $email = ( is_email( $email ) ) ? $email : '';
    $rows['user_email']['field'] = '<input type="text" value="' . $email . '" />';
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.