Home Forums ACF PRO Front-facing form for multiple posts on archive page, one update button


Front-facing form for multiple posts on archive page, one update button

  • Hi folks, I have emailed support but thought I’d ask the community to see if anyone has come across this before.

    We’re using a modified version of WooCommerce to allow a customer to order prints from a photo shoot. The photos are essentially a product post type, and are listed in a customised version of the Woo product archive. We want the customer to be able to rate each photo from 1 to 5 using radio buttons. So we made the field, and I’ve created a little plugin to pull in that field into a Woo hook.

    The following code has got me nearly there, but there’s one issue and one other thing I’d like it to do:

    function photo_rating() {
    		echo the_field('rating_2');
    		echo acf_form();

    along with the <?php acf_form_head(); ?> code.

    What happens now is that each photo is listed in the product archive as normal, plus our radio buttons. As it’s a front facing form there’s also an ‘update’ button underneath each set of radio buttons.

    I can click a rating and press update, and the post (the photo product) is updated, which is great. However, when you do press update, it takes you to a blank page (though the page is themed still). With debug mode on I can see these errors:

    Warning: Cannot modify header information - headers already sent by (output started at /home/s7media/public_html/test/everythingbetween/wp-includes/functions.php:3897) in /home/s7media/public_html/test/everythingbetween/wp-includes/pluggable.php on line 1167

    I’ve looked for white space as usual with this error, removed it, and no luck I’m afraid.

    So that’s the first thing.

    The other thing is that this would be a long process to press update on each photo (there will be dozens). Is there any way of removing the update button from each post in the archive, and instead having one update button which will update all posts at once?

    You can see a bit of a screenshot here:

  • As for the first problem, something you’re doing is causing a PHP error. You can try enabling debugging, you need to see what the PHP warning is before the error you posted to figure out where there problem is.

    As for the second part of the question, my suggestion would be to use acf_form with the form option set to false. This would output the fields without the <form> tags. Then build AJAX to do the needed updating. This will be pretty complicate to be honest and I’m not sure of all of the things you need to deal with though and it may take even more modification since you’ll need to somehow associate each field with the correct post. In the end though, it would create a better user experience.

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

The topic ‘Front-facing form for multiple posts on archive page, one update button’ is closed to new replies.