Skip Navigation

[Resolved] Automatically selecting the post to add a RFG to, in front-end form

This thread is resolved. Here is a description of the problem and solution.

Problem:
Automatically selecting the post to add a RFG to, in front-end form

Solution:
you can use the Toolset Form's hook "cred_save_data" and to set/connect the parent post, you can use the post-relationship API function: toolset_connect_posts()

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/automatically-selecting-the-post-to-add-a-rfg-to-in-front-end-form/#post-1784371

Relevant Documentation:
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created 3 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by rotimiA 3 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1783427

Currently, this site is on a localhost installation.
As described in:
https://toolset.com/course-lesson/front-end-forms-for-repeatable-field-groups/
"Forms that submit information using repeatable field groups must feature a field to select the parent post. Otherwise, the submitted information cannot be retrieved and used. This field is automatically included in the form, just make sure not to remove it."
However, this will not work for my use case. The RFG will be edited by users on a membership site, so I do not want them to be able to select another users post to add their RFG data to. In other words, I need to automatically set the parent post upon submission of the front end form.
I would prefer to do this with some backend code that queries the current user and intercepts the form processing if possible. It is not secure if this is done in a hackish way with javascript or hidden fields as I saw suggested in another post on a related topic. Because a user could alter the front-end code and submit information to another users pages anyway.

I am sure someone has had this use case before but I was unable to find a suitable solution.

#1784371

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There are couple of ways you can achieve this.

First solution is you can hide your parent field by adding some custom CSS so your users wont see the field and form will work as expected.

And another way is - you can use the Toolset Form's hook "cred_save_data" and to set/connect the parent post, you can use the post-relationship API function: toolset_connect_posts
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

Please check the following related ticket where I shared the solution, that may help you:
=> https://toolset.com/forums/topic/i-need-to-automatically-set-the-related-post-directly/#post-1082747

#1784441

My issue is resolved now. Thank you!

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