Skip Navigation

[Resolved] Saving 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Shane 5 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1186818

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
I can't find the code anywhere.
Could you help me with that ?
Thanks in advance,
Mat

#1186856

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

I don't think that we have an API solution for this.

However what I can do is to check with our 2nd tier support team to see if they are aware of any solution for this.

Thanks,
Shane

#1186996

Yes could you check with them for me ?
That's would be great as I'm stuck with this problem.
I choose to buy Toolset Types for this feature (field group).

#1187972

I used the following code to GET the Field Group Data

$args = array(
  'post_type' => 'specificites-tech',
  'numberposts' => -1,
  'toolset_relationships' => array(
    'role' => 'child',
    'related_to' => $post->ID,
    'relationship' => 'specificites-tech'
  ),
  'order' => 'ASC'
);
$the_query = new WP_Query( $args );

But what should I use to SAVE them ?

#1188112

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

As you are aware RFG are just posts.

So to do it programmatically you will need to follow the example below.

//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 );
//Add Fields to the RFG
update_post_meta($new_rfg_id , 'wpcf-slug_of_field_of_rfg', 'value to insert');
//Now connect the new RFG to a Post
toolset_connect_posts('rfg_slug', $post_id_to_which_rfg_belongs, $new_rfg_id);

Please let me know if this helps.

Thanks,
Shane