Add custom fields to the vendor's settings form

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Add custom fields to the vendor's settings form

Viewing 6 reply threads
  • Author
    Posts
    • #36630
      Rami
      Participant

      Hi, I use WCFM Ultimate and WcMarketplace in my website, my vendors are teachers, and I need them to add topics they teach in their shop page under the description.
      I have ACF Pro, but I think it works only in the add product page in WCFM not in the pages, so I need your advice on this..
      In short:
      I need the vendor to add the topics he teach as custom fields in his wcfm settings page (preferably repeater field but if can’t a text area will do the job) , and these fields have to be displayed in his shop page under the description.
      for displaying the fields in the shop page, I think I can do that by editing wc-marketplace file “archive_vendor_info.php”, but still the first part that I can’t figure out.

      Thanks in advance.

    • #36704
      Rami
      Participant

      Hi again,
      I succeeded in adding the desired field in the vendor’s setting page using the following code:

      add_filter ( ‘wcfm_wcmarketplace_settings_fields_general’ , ‘add_teacher_topics’ ,20 );
      function add_teacher_topics($settings_fields_general){
      $settings_fields_general[‘teacher_topics’]= array(
      ‘title’ => __( ‘Topics I Teach’, ‘wc-frontend-manager’ ),
      ‘type’ => ‘text’,
      ‘priority’ => 50,
      ‘class’ => ‘wcfm-text wcfm_ele’,
      ‘label_class’ => ‘wcfm_title wcfm_ele’,
      );
      return $settings_fields_general;
      }

      but I have the following issues:
      1) When adding any data to the field and saving, it is not saved, i.e:the field remains blank after saving.
      2) how can the field content be displayed in the store (shop) page of the vendor as does the description field for example.
      3) I keep having an issue in saving or submitting anything in WCFM dashboard in general, which is the curser keeps spinning for infinity after clicking “save” button. The settings or fields are being saved but the only way to get rid of the spinning wheel is to refresh the page or go to another page. I have no errors in chrome console before saving, but after saving and appearance of the issue I have an error related to the wp admin ajax.

      I hope to have some help here.
      Thanks….

    • #36880
      WCFM Forum
      Keymaster

      HI,

      That’s Great 🙂

      1. Use this hook to save those data -> do_action( ‘wcfm_vendor_settings_update’, $user_id, $wcfm_settings_form );

      2. Use this short code in store side bar to make those visible – [wcfm_store_info data=”teacher_topics”]

      3. Some error is generating, kindly open Google Chrome browser console and take a look. Also check at wp-admin -> WooCommerce -> Status -> Logs

      Thank you

    • #36909
      Rami
      Guest

      Hi, Thank you for your help but I think the code doesn’t work or I am missing something here, here is the code after adding the new hook you suggested:

      add_filter ( ‘wcfm_wcmarketplace_settings_fields_general’ , ‘add_teacher_topics’ ,20 );
      function add_teacher_topics($settings_fields_general){
      $settings_fields_general[‘teacher_topics’]= array(
      ‘label’ => __( ‘Topics I Teach’, ‘wc-frontend-manager’ ),
      ‘type’ => ‘text’,
      ‘priority’ => 50,
      ‘class’ => ‘wcfm-text wcfm_ele’,
      ‘label_class’ => ‘wcfm_title wcfm_ele’,
      );
      return $settings_fields_general;
      }

      do_action( ‘wcfm_vendor_settings_update’, $user_id, $wcfm_settings_form );

      1) I still have the same situation, where the field content not being saved after saving, and I have the following errors:
      Undefined variable: user_id
      Undefined variable: wcfm_settings_form

      2) I tried to put the shortcode in a text widget in the sidebar, but it doesn’t work, it only displays the shortcode itself instead of the contents.

      3) for the spinning wheel issue, I have the following error in chrome console:
      Failed to load resource: the server responded with a status of 502 () /wp-admin/admin-ajax.php:1

      *** Thank you very much.

    • #36948
      WCFM Forum
      Keymaster

      Hi,

      1) I still have the same situation, where the field content not being saved after saving, and I have the following errors:
      Undefined variable: user_id
      Undefined variable: wcfm_settings_form

      ** Please show me what code you have written for save.
      do_action( ‘wcfm_vendor_settings_update’, $user_id, $wcfm_settings_form ); – this is the hook for which you have to write code for save.

      2) I tried to put the shortcode in a text widget in the sidebar, but it doesn’t work, it only displays the shortcode itself instead of the contents.

      ** Please show me screenshot what you have added in widget!

      3) for the spinning wheel issue, I have the following error in chrome console:
      Failed to load resource: the server responded with a status of 502 () /wp-admin/admin-ajax.php:1

      ** Opps!! “/wp-admin/admin-ajax.php” – this WP core file, why it can’t be loaded? I think there has some file permission issue!

      Thank You

    • #37041
      Rami
      Participant

      Hi,
      1) saving field issue has been fixed when I fixed the Ajax issue which is related to another plugin called “Query Monitor”. and I am sorry, but I only added the hook to the functions.php file. Is there any additional code to add to save the field content? If yes, can you help with it please?

      2) I will attach a screen shot for the shortcode widget settings, but I wonder, does it work with wc-marketplace, which I use?

      3) solved by deactivating the “Query Monitor” plugin as mentioned in “1” above.

      Thanks.

      Attachments:
      You must be logged in to view attached files.
    • #37080
      WCFM Forum
      Keymaster

      Hi,

      2) I will attach a screen shot for the shortcode widget settings, but I wonder, does it work with wc-marketplace, which I use?

      – Opps! I thought you are using WCFM Marketplace. Please contact WC Marketplace forum regarding this.

      Thank You

Viewing 6 reply threads
  • The topic ‘Add custom fields to the vendor's settings form’ is closed to new replies.