Add custom field in registration form

Theme and Plugin Support

Resolved
Viewing 8 reply threads
  • Author
    Posts
    • #135698
      t.sarsevanidze
      Participant

      Hello, I want to add a custom field in registration form. added in templates/shortcode/vendor_registration.php . how to access to save this as a customer user meta as separeted?

    • #135699
      t.sarsevanidze
      Participant

      is there any hook that I can save my own created field?

    • #135704

      Hi,
      To save registration user meta, use below code-

      add_action( 'user_register', 'set_user_custom_data', 10, 1 );
      function set_user_custom_data( $user_id ) {
         	if (isset($_POST['new_text'])) {// your input type name
         		// Update the registration meta data
          	update_user_meta ( $user_id, 'test', $_POST['new_text'] );// your input type name
         	}
      }
      Copy

      NOTE – Kindly change the name as per the added code.

      Regards,

    • #135706
      t.sarsevanidze
      Participant

      in vendor registration I have added this https://prnt.sc/9-ylxq5jsLIe its in /shortcode/vendor_registration.php

      and also in functions.php I have added that snipped but it doesn’t worked my edited code snippet is next https://prnt.sc/eQ9cylbLRWyR

    • #135707
      t.sarsevanidze
      Participant

      In vendor registration I have added this https://prnt.sc/9-ylxq5jsLIe its in /shortcode/vendor_registration.php
      and also in functions.php I have added that snipped but it doesn’t worked my edited code snippet is next https://prnt.sc/eQ9cylbLRWyR

    • #135709
      t.sarsevanidze
      Participant

      tried a lot of variations but

      its not saved https://prnt.sc/VyJYG2WSEaM2

      In vendor registration I have added this https://prnt.sc/9-ylxq5jsLIe its in /shortcode/vendor_registration.php
      and also in functions.php I have added that snipped but it doesn’t worked my edited code snippet is next https://prnt.sc/eQ9cylbLRWyR

    • #135713
      t.sarsevanidze
      Participant

      // In vendor registration I have added this https://prnt.sc/9-ylxq5jsLIe its in /shortcode/vendor_registration.php
      // and also in functions.php I have added that snipped but it doesn’t worked my edited code snippet is next https://prnt.sc/eQ9cylbLRWyR

    • #135727

      Can you please explain what are you referring to as “is it possible also it to edit in vendor dashboard and vendor admin panel?”, so we can assist you.

      • #135728
        t.sarsevanidze
        Participant

        just that when user selects its own category. to allow also to change it in storefront settings.

        user_register function that u sent me doesn’t worked. can u help

    • #135754

      Hi,
      I have added a custom text field and save the data into the data base using below code

      // kindly add below code to the function.php of your active theme folder
      add_action( 'user_register', 'set_user_custom_data', 10, 1 );
      function set_user_custom_data( $user_id ) {
      	//
         	if (isset($_POST['new_text'])) {// your input type name
         		// Update the registration meta data
          	update_user_meta ( $user_id, 'test', $_POST['new_text'] );// your input type name
         	}
      }
      
      add_action('wcmp_vendor_register_form', 'wcmp_custom_select_field');
      function wcmp_custom_select_field() { ?>
      	<div class="wcmp-regi-12">
              <label for="test"><?php _e('test', 'dc-woocommerce-multi-vendor'); ?> <span class="required">*</span></label>
              <input type="text" required="required" name="new_text" id="new_text" />
          </div>
      <?php
      }
      Copy

      Kindly checkout the video – https://gdskavr9sw.vmaker.com/record/1Mk5Xpavj1fd4BYy

      Regards,

Viewing 8 reply threads

The topic ‘Add custom field in registration form’ is closed to new replies.