Tell us what you are trying to do? - I'm trying to list posts which fall under certain categories/taxonomies (which are passed via POST or GET or cookies or a form sumbit).
Is there any documentation that you are following? - I couldn't find any!
Is there a similar example that we can see? - I can show via screenshare what I'm trying to do.
What is the link to your site? - The link wouldn't work outside VPN.
I have a Toolset Form for the user to submit which has taxonomies. Now, as an action of that submit button, I want user to go to a page where I want to show the list of items filtered by the taxonomies the user selected in the Toolset Form he/she submitted.
One way, I think this should happen is to include the selected taxonomies in the URL while we submit the form.
Any idea how can I do it? This is basically the reason I wanted Toolset in the first place.
Thank you for your support so far, Minesh. Looking forward.
add_filter('cred_success_redirect', 'func_redirect_to_custom_page',10,3);
function func_redirect_to_custom_page($url, $post_id, $form_data) {
$assigned_terms = wp_get_object_terms( $post_id,'taxonomy-slug',array('fields'=>'slugs'));
if ($form_data['id']==9999) {
$url = ""; // adjust your URL with params here
}
return $url;
}
Where:
- Replace 9999 with your original form ID and 'taxonomy-slug'
Where within this hook, as you can see we get the assigned terms using the wp_get_object_terms() which will return the term slugs array and you can use this term slug array and pass it as URL param.
Ok, I'm trying this right now. However, I'm facing challenges while submitting the form.
Why is it mandatory to add/edit a post after submitting a form? I just want to redirect to a page with the selected parameters in query string and nothing else.
It is not redirecting to that page (via above hook) and rather loading the same page with ?cred_referrer_form_id=122 added to the URL (but stay on the same page).
Why this Form type is mandatory to select? It is a simple form which just submits values to a page (and doesn't create/edit any post/page).
Well, Toolset offers three kind of forms:
- post forms (using which you can either create/edit entry for specific post type to which form is attached)
- user forms (using which you can either create/edit users)
- post-relationship forms (using which you can connect the post in pot-relationship)
So, if you created the post form, then either you need to set to create a entry or edit the existing entry.
And as you can see with the following hook, if you want to run the following hook:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
- You need to make sure that:
Please note that for the redirection hooks to work, the form must be set to redirect to a specific page or a post after the submission. If for example, the form options are set to “Keep displaying this form” or “Display a message instead of the form” after submission, the redirection hooks will not work.
However, I don't want post/user/relationship forms. I just need a simple form which has fields filled with custom post's taxonomies and submitting that form will open a new page with the list of items filtered through the items selected in the form (which was submitted).
Any idea how can do this with Toolset Form/View/Blocks?
There is no such form available. If you want to use the redirection hook I shared, you must create a post form using Toolset.
I am still not clear why you want to create such form as you did not shared the clear requirement.
Maybe you can create a dummy edit form but I would like to know what taxonomy you want to pass as URL param and to what post type the taxonomy is assigned currently.