Hi I am trying to add in a row to a custom field through the front end. I followed these methods:
http://support.advancedcustomfields.com/forums/topic/add-row-to-repeater-field-from-the-frontend/
Which worked but was adding in blank rows. I have subsequently deleted all rows and added in a new one via the backend, but when I var_dump the field I get an array of 5 blank rows.
Any ideas guys?
If you use the_form() to add a form on the front end, http://www.advancedcustomfields.com/resources/acf_form/. You can specify what field groups and specify what fields to show. Using the hook acf/pre_save_post you can then create new posts if you need to http://www.advancedcustomfields.com/resources/acf-pre_save_post/. Users will be able to upload images using acf_form().
Hi John,
Cheers for the help, I didn’t realise acf have a form. I solved it another way, by using ajax.
<?php
// This allows our page to have wordpress knowledge
define('WP_USE_THEMES', false);
require_once('../../../wp-load.php');
$userid = $_REQUEST['userid'];
$email = $_REQUEST['email'];
$username = $_REQUEST['username'];
$pageid = $_REQUEST['pageid'];
$attendFB = $_REQUEST['attendFB'];
$update_field = new WP_Query('showposts=1&post_type=tribe_events&orderby=date&order=ASC&p='.$pageid );
while ($update_field->have_posts()) : $update_field->the_post();
the_title();
//get attending rows
if( have_rows('attending') ){
$gallery = get_field( 'attending' );
} else {
$gallery = array();
}
// add to existing array
$gallery[] = array(
'user_id' => $userid,
'name' => $username,
'email' => $email
);
// save new array
update_field("field_identifier", $gallery, get_the_ID());
endwhile; wp_reset_query();
?>