Support

Account

Home Forums Front-end Issues ACF Front-end Form + Woocommerce

Solved

ACF Front-end Form + Woocommerce

  • Hello,
    I’ve added acf front-end form to my-account.php which is WooCommerce default page.
    It looks like this:

    <?php
    /**
     * My Account page
     *
     * @author 		WooThemes
     * @package 	WooCommerce/Templates
     * @version     2.0.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    acf_form_head();
    wc_print_notices(); ?>
    
    <p class="myaccount_user">
    	<?php
    	printf(
    		__( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
    		$current_user->display_name,
    		wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) )
    	);
    
    	printf( __( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),
    		wc_customer_edit_account_url()
    	);
    	?>
    </p>
    
    <?php do_action( 'woocommerce_before_my_account' ); ?>
    
    <?php wc_get_template( 'myaccount/my-downloads.php' ); ?>
    
    <?php wc_get_template( 'myaccount/my-orders.php', array( 'order_count' => $order_count ) ); ?>
    
    <?php wc_get_template( 'myaccount/my-address.php' ); ?>
    
    <?php acf_form(array(
    	'post_id' => 'user_'.get_current_user_id(),
    	'submit_value'	=> 'Save devices list' 
    	)); ?>
    
    <?php do_action( 'woocommerce_after_my_account' ); ?>

    This form allows users to fill repeater field connected with their account. It works, but when the user pushes “save” button he got warning:

    Warning: Cannot modify header information - headers already sent by (output started at S:\Kasy fiskalne\kod\prod\public_html\wp-includes\admin-bar.php:844) in S:\Kasy fiskalne\kod\prod\public_html\wp-includes\pluggable.php on line 1178

    Have anyone the same situation or know what should I do to repair it?

  • Ok, i’ve solved it by using ob_start() in header.php and ob_end_flush() in footer.php

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

You must be logged in to reply to this topic.