Skip Navigation

[Resolved] Pre-fill repeating fields in CRED

This support ticket is created 7 years, 8 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 – 10:00 - - - - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 3 replies, has 3 voices.

Last updated by Mohammed 7 years, 8 months ago.

Assisted by: Mohammed.

Author
Posts
#424977

Hello,

Sorry I have not been able to find this in the forums, otherwise I would not create a ticket.

How can I pre-fill repeating fields in CRED? If I have a custom type, lets call it "Reviews" with a custom repeating field. I want a CRED form that retrieves the data from a Review and based on it, creates a new one. In other words, it should create X number of repeating fields as the original template, then prefill them and on submit, create a new Review.

I can't find how to loop and create the number of repeating fields and filling them?

Many thanks

#425223

Hello,

Well, you will need some custom code to achieve that, I'll give you some insights. First you must understand that repeating fields are normal custom fields containing the same meta key for the same post, so as soon as you have at least 2 fields with same meta key and same post ID, so you have a repeating field.

Given that you can use CRED API, cred_submit_complete: https://toolset.com/documentation/user-guides/cred-api/#csc

You can make a foreach to add as many custom repeating fields to a post as you want:

add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
   while( something ){
        add_post_meta( $post_id, 'my_key', 'my value' );
   }
}

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,

Adriano Ferreira

#425280

Thanks Adriano.

However, I don't think we're on the same channel. The code you have kindly given me is intended to do something when a CRED is submitted, correct?

I need something different.

1. I have data already in the database, submitted through the backend, using repeating fields.

2. I want now a front-end CRED form AND to pre-fill it with that data - which means also creating the correct number of repeating fields and filling them with the data from the post.

3. This way, when the user submits the form, it will create a new post, but having used the data from the database as a starting point. So it is some kind of hybrid between editing an existing post but really creating a new one.

Does this make sense?

Many thanks for your help

#428015

Hello Hector,

I’m Mohammed: the Toolset support team leader. I’ll give my best to help you to achieve your needs through Toolset components.

It seems you need custom programming work which is beyond the scope of our support.
At this point, I would suggest you consider contacting one of our certified partners from this link: https://toolset.com/consultant/
You will get the custom assistance you need to get on with your project.
Before doing so please have a look also here: https://toolset.com/toolset-support-policy/

Thanks.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.