• Skip to primary navigation
  • Skip to main content

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
  • Store
    • Cart
    • Checkout
  • Blog
    • Basics [Free]
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Contact
  • Sign In
  • Show Search
Hide Search
Home » Actions » Request additional data fields on a specific page

Request additional data fields on a specific page

Chad Butler · Apr 20, 2014 ·

This particular example is a generic tutorial for requesting additional data fields in the registration form on a specific page. Since these are fields that do not show up in the regular registration form, we need to also present the data to logged in users to add this data.

While conceptually this is not an overly complicated process, the practical implementation has quite a few steps, so I will try to explain each step in the process while giving that particular code snippet being discussed at that point.

This article is only available to WP-Members Support Subscribers. If you have an existing subscription, please login below. If you do not have a current support subscription, you can purchase a support subscription here.

Already a Member? Log In Here
   
Forgot password? Click here to reset

To gain full access to WP-Members premium content, a current support subscription is required. You can purchase an annual support subscription for as little as $59, which provides you with access to priority support, a customer support forum, access to code snippets, and more.

Why wait? Choose your subscription option here.

[
Why join?]

Actions, Filters, Tips and Tricks is_page, is_user_logged_in, the_content, wpmem_email_notify, wpmem_post_update_data, wpmem_pre_register_data, wpmem_register_form_before, wpmem_register_form_rows, wpmem_register_heading, wpmem_user_edit_heading

Welcome to RocketGeek Interactive › Forums › Request additional data fields on a specific page

Tagged: is_page, is_user_logged_in, the_content, wpmem_email_notify, wpmem_post_update_data, wpmem_pre_register_data, wpmem_register_form_before, wpmem_register_form_rows, wpmem_register_heading, wpmem_user_edit_heading

  • This topic has 5 replies, 2 voices, and was last updated 6 years, 7 months ago by Chad Butler.
Viewing 1 reply thread
  • Author
    Posts
    • April 20, 2014 at 9:38 pm #4694
      Chad Butler
      Keymaster

      This particular example is a generic tutorial for requesting additional data fields in the registration form on a specific page. Since these are field
      [See the full post at: Request additional data fields on a specific page]

    • September 8, 2014 at 8:51 am #5816
      dtmnash
      Participant

      On my extra fields only page I’m getting validation errors on the fields that aren’t being captured (firstname for example).

      Do all fields need to be marked as not required for this to work?

      • September 8, 2014 at 9:53 am #5817
        Chad Butler
        Keymaster

        If the fields are going to not be displayed for one form state (such as new registration) but would be shown in a different form state (such as user profile update), then that is correct – you cannot set them as required.

        Take note of the first section “Preparation”:

        While this data will be required on our special page, do not set the fields as required in the field manager tab. We will handle their validation separately when the form is submitted.

        The reason for this is that the registration/profile update function goes through all the fields, not just the ones that are being displayed. So if a form field is required, but is not displayed, there will be no data for it and it will be checked and found invalid (empty).

        So if the field is going to be required when it is displayed, you’ll be adding validation for that as part of the customization. See the section “Add form validation for the extra fields.”

        Hope that helps clarify.

        • September 9, 2014 at 5:49 pm #5826
          dtmnash
          Participant

          it does help, the tutorial should call out that you need to set all other fields to not required though. firstname is not an extra field, it’s part of wp members.

          • September 9, 2014 at 6:37 pm #5828
            dtmnash
            Participant

            After spending some more time with the samples above I was able to tailor this to my use case.

            My Use Case: Have a page where *only* the extra fields are editable.

            What I did – it’s quick and dirty but it stops the user from (easily) being able to edit fields I don’t want them to on this page.

            
            wpmem_ef_add_extra_fields( $rows ){
                if( ! is_page( 'extra-fields-page' ) ) {
            
                  unset( $rows['extra_field1']  );
                    unset( $rows['extra_field2'] );
            
            }
            else{
                    $rows = hide_field_in_form('subscription_type', $rows);
                    $rows = hide_field_in_form('first_name', $rows);
                    $rows = hide_field_in_form('last_name', $rows);
                    $rows = hide_field_in_form('addr1', $rows);
                    $rows = hide_field_in_form('addr2', $rows);
                    $rows = hide_field_in_form('city', $rows);
                    $rows = hide_field_in_form('thestate', $rows);
                    $rows = hide_field_in_form('zip', $rows);
                    $rows = hide_field_in_form('user_email', $rows);
                    $rows = hide_field_in_form('phone1', $rows);
                        
                    $rows['extra_field1']['label'] =
                        '<label for="extra_field1" class="text">extra_field1<font class="req">*</font></label>';
                        
                    $rows['extra_field2']['label'] =
                        '<label for="extra_field2" class="text">extra_field2<font class="req">*</font></label>';
                        
            }
            function hide_field_in_form($field, $rows)
            {
                    $rows[$field]['field_before'] = '<div class="div_text" style="display:none;">';
                    $rows[$field]['label'] = '';
                    return $rows;
            }
            
          • September 9, 2014 at 11:26 pm #5830
            Chad Butler
            Keymaster

            Sorry if it wasn’t clear. What I meant by “extra fields” was the fields that would be displayed on one form but not the other. Hope that clarifies.

  • Author
    Posts
Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Log In

Ready to get started?

Join Today!

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

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