Support

Account

Home Forums Front-end Issues acf_form, Woocommerce and user image field Reply To: acf_form, Woocommerce and user image field

  • Hi @jamesryder

    I’m not sure but I think your issue _might_ be due to where you’ve placed acf_form_head.

    It should be located before any output and currently you’re placing it smack in the form.

    Try this:

    
    <?php
    /**
     * Output ACF form functionality on the edit account page in woocommerce
     */
    function add_acf_head_to_wc(){
    	if( is_wc_endpoint_url() ){
    		acf_form_head()
    		
    	}
    	
    }
    add_action( 'template_redirect', 'add_acf_head_to_wc', 1000 );
    
    /**
     * Output our ACF image field in the WooCommerce edit account form
     */
    function woocommerce_edit_account() {
    	acf_form(array(
    		'field_groups' => array(931), 'form' => false
    	));
    
    }
    add_action( 'woocommerce_edit_account_form', 'woocommerce_edit_account', 10 );
    
    /**
     * Do an ACF save action on the user. 
     * NOTE: I'm not sure this is even needed..? 
     */
    function my_woocommerce_save_account_details( $user_id ) {
    	// $post_id to save against
    	$post_id = 'user_' . $user_id;
    	// update the post
    	do_action('acf/save_post', $post_id);  
    	
    }
    add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );