Home Forums ACF PRO Saving a cloned repeater field on a registration form


Saving a cloned repeater field on a registration form

  • I’m using acf_form() to snag a 3x cloned repeater and drop it into a WPForms user registration form. WPForms comes with a handy set of matching their fields to ACF ones, but since I’m employing acf_form(), that option is off the table.

    I’ve done a ton of research looking for a way to save the repeater fields to a newly registered user, but most everything I’ve come across is about using ACF to register the user and then adding in whatever custom fields during the registration process. I’ve also seen a bit of info on update_user_meta(), but since I have a 3x cloned repeater (with 10~ entries per row, up to 3 rows per repeater), that’s like 90+ entries – which doesn’t seem like the right way to do it.

    I have come across the native WP action of user_register, which fires immediately after a user is registered, giving you access to their ID, and before all other data is sent to the database, but I can’t seem to find a way to attach all of the acf_form() cloned repeater data to that action without a zillion update_user_meta entries.

    WPForms documentation also sucks, btw. So trying to hook into any of their actions will require getting very, very familiar with their plugin’s code.

    Here is my super-simple acf_form() dropped into a shortcode function (so I can toss it into an HTML field of WPForms). The fields are Tab 01, Clone 01->Repeater 01, Tab 02, Clone 02->Repeater 01, Tab 03, Clone 03->Repeater 01, which is exactly how they display on the users’ profile page.

    function user_credits_form( $atts ){
    	$settings = array(
    		//'post_id'      => 'user_'.$user_id,
    		'fields' => array('field_5b2878966ac10', 'field_5b2878c16ac11', 'field_5b4440c1e2d20', 'field_5b444105e2d22', 'field_5b4440cae2d21', 'field_5b444141e2d23'),
    		'form' => false
    	return acf_form($settings);
    add_shortcode( 'user_credits', 'user_credits_form' );

    And here are examples of an input and its’ subsequent database entry from Clone 02->Repeater 01->Row 02->Group Project Details->Text Field (oh yeah, I also have groups in there). All of these items save + update just fine from a users’ profile page, too.

    <input id="acf-field_5b444105e2d22-field_5b2877cb5686b-0-field_5b2877cb579ea-field_5b2877cb5ed3e" name="acf[field_5b444105e2d22][field_5b2877cb5686b][0][field_5b2877cb579ea][field_5b2877cb5ed3e]" placeholder="Project Name / Show Title" type="text">
    DB Entry – credits_2_user_credits_1_project_details_project_name

    Last bit of info
    Yes, I have acf_form_head() above my get_header() function.
    I’ve looked into wp_insert_user, wp_update_user, acf_pre_save_posts, and so on… user_register seems to be the most viable and, with any luck, the laziest solution.

    I’m really hoping that I’m just missing something obvious here.

Viewing 1 post (of 1 total)

The topic ‘Saving a cloned repeater field on a registration form’ is closed to new replies.