Skip Navigation

[Resolved] Programmatically save repeatable field group

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1187973

Hi there,

I'm trying to programmaticaly save repeatable field group.

I've read it's like a post relationship so i've tried to save it with the function "toolset_connect_posts" but it didn't worked and I can't find the code anywhere.

Could you help me with that ?
Thanks in advance,
Mat

#1188007

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Mat

We have an internal ticket to improve the documentation for this.

It is not well explained, but where you would use the relationship slug, with repeatable field groups this is simply the slug of the RFG, so your code might look something like this:

//Create a new RFG Item
$new_rfg = array(
  'post_title'    => 'New RFG Item Title',
  'post_status'   => 'publish',
  'post_type' => 'slug_of_rfg'
);
$new_rfg_id = wp_insert_post( $new_rfg );

//Now connect the new RFG to a Post
toolset_connect_posts('rfg_slug', $post_id_to_which_rfg_belongs, $new_rfg_id);

Let me know if you have problems implementing that.