Skip Navigation

[Resolved] Making front end forms for repeating field groups work

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

Problem:

After submit the post form for creating repeating field group item, redirect to the original post.

Solution:

See detail steps here:
https://toolset.com/forums/topic/making-front-end-forms-for-repeating-field-groups-work/#post-1125151

Relevant Documentation:

This support ticket is created 6 years, 1 month 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by fredr 6 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1124649

Tell us what you are trying to do?

THE PROJECT AND CONTENT TYPE :

I am developing a website (in french).

I have a content type (film declaration - it is an administrative website) with two repeating field groups :
- contributor
- lieu de travail (workplace).

I need my users to fill their declarations from the front-end.

I HAVE BEEN ABLE TO :

- Create the basic form
- Add a "new contributor" and "new workplace" link to the pages where I have included the forms for these repeating field groups
- add contributors and workplaces
- Display them when I go back to the original document (declaration)

THE PROBLEM :
What I cannot figure is stupid and hopefully very simple : How is it possible, when validating the creation of a new repeating field group, to be redirected to the parent page - with the new occurence of the repeating fields loaded - ? I have no clue. The proposed actions include nothing like that...

Is there any documentation that you are following?

I managed to do all that with the help of this :
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/front-end-forms-for-repeatable-field-groups/

Is there a similar example that we can see?
?

What is the link to your site?

hidden link
[password to access the site : reaumur ]

You can add access the form at : hidden link
You can see the list of films at : hidden link
Example of a film with successfully created contributors and workplaces : hidden link

#1125151

Hello,

It needs custom codes, and the custom field group works similar as one-to-many relationship, for example, when user submit the form for creating "contributor" post, you can use filter hook "cred_success_redirect" to trigger a custom PHP function
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

in this function, get the related "film declaration" post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

With the post ID, return the "film declaration" post URL:
https://developer.wordpress.org/reference/functions/get_permalink/

For your reference.

#1125168

My issue is resolved now. Thank you!

#1127626

For anyone reading this thread and interested in the full solution, here is what I did :

add_filter('cred_success_redirect_3425', 'lmplw_get_parent_link_3425',10,3);

function lmplw_get_parent_link_3425($url, $parent_id)
{
$parent_id = $_GET['parent_declaration_id'];
$url= get_permalink($parent_id,true);
return $url;

}

COMMENTS :
==========
Filter -> Create a filter using cred_success_redirect ( 3425 is the ID of my form.)
Function :
Line 1 -> Get the parent id from the URL (easier in my case than using the toolset_get_related_post function)
Line 2 -> Get the permalink from the parent id
Line 3 -> the form is redirected to the parent post

(Important : do not forget to configure your front-end form to redirect to a page or post or you'll spend the day on it...)