Support

Account

Home Forums Front-end Issues ACF + WC Vendors front dashboard

Solved

ACF + WC Vendors front dashboard

  • Hi,

    I would like to display some fields on the dashboard of my vendors but nothing is displayed !

    https://www.wcvendors.com/kb/pro-adding-advanced-custom-fields-acf-support/

    This is my code :

    
    add_action('wcvendors_settings_after_shop_name', 'wcv_save_acf_fields');
    function wcv_save_acf_fields() {
        acf_form_head();
    }
    
    add_action('wcvendors_settings_after_seller_info', 'wcv_add_acf_fields');
    function wcv_add_acf_fields() {
           echo 'user:' . get_current_user_id(); 
    
    	acf_form( array('form' => false,
    		'fields_group' => 521,
    		‘return’ =>false,
    		'post_id' => get_current_user_id() 
    	) );
    
    	acf_form(array('form' => false,'fields_group' => 730));	
    
    }
    

    but nothing is displayed.
    get_current_user_id() is successfully echoed.

    acf_form(array(‘form’ => false,’fields_group’ => 730));
    is working fine if I place this in the checkout page….

    Any idea ?

  • Hi @marc-bovetgmail-com

    Just like the code in the link you’ve shared, you should use the following code for the post_id option:

    'post_id' => WCVendors_Pro_Vendor_Controller::get_vendor_store_id( get_current_user_id() )

    That code should get the vendor store ID (which is a post type, I believe) so you can get the data from that store post type.

    If you want to add it to the user dashboard instead of the store post type, then you need to do it like this:

    'post_id' => 'user_' . get_current_user_id()

    This page should give you more idea about it: https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/.

    I hope this makes sense 🙂

  • Hi James,

    Thank you for your answer.

    I’ve already tried both syntax :
    'post_id' => 'user_' . get_current_user_id()
    and
    'post_id' => WCVendors_Pro_Vendor_Controller::get_vendor_store_id( get_current_user_id() )

    but none is working, the fields are not shown.
    If I set ‘form’ => true, then the update button is displayed.

    What else can I do ?
    Thank you for your help.
    Marc

  • Hi James,

    Got it !

    From backend : Custom Fields
    Location, Rules, Show this field group if “Current user” is equal “Viewing front end” !

    solved my problem…

    cheers

  • Hi.
    If I set:
    “Current user” is equal “Viewing front end” ! – field appears in vendor dashboard
    and if i set “Current user” is equal “Viewing back end” field appears in User info.
    https://dl.dropboxusercontent.com/s/enuigvqqbseaog4/shot_170301_003927.jpg

    When i add some text in vendors field and click SAVE, this text tont appear in user info field. How to conect this two fields?

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘ACF + WC Vendors front dashboard’ is closed to new replies.