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
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.
My issue is resolved now. Thank you!
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...)