Skip Navigation

[Resolved] How to use submitted post form data as success page view filter parameters

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
- 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 3 replies, has 2 voices.

Last updated by Minesh 1 year, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2609071

Tell us what you are trying to do?
I have a form that captures various parameters regarding visitor sightings of wildlife. On successful submission, I would like to pass this data to another 'thanks for your submission' page with a custom view. Presumably this data would be passed as http link parameters. It will be somehow used in the filters on the success page view, so the visitor can see a list of posts relevant to their submitted information.

Is there any documentation that you are following?
I'm hoping you can help me find documentation on passing parameters.

Is there a similar example that we can see?
Can you please show me examples?

What is the link to your site?
There's nothing to see yet, but it's hidden link

#2609203

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

You can use the Toolset Form hook "cred_success_redirect" and you can redirect user to your desired link with URL params.

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

#2609957

Thanks Minesh!

The redirect to the view page works. I have included an argument for the post_id that was submitted. It has the format .../page-with-view/?post-id=12345&cred_referrer_form_id=54321

Next I built a view and added it to the redirect page via its shortcode.

On arrival to the redirect page, is there a way to extract the post_id argument, look-up a custom taxonomy value from the post_id, then use this as a filter for the view in the page?

#2610035

Minesh
Supporter

Languages: English (English )

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

You can use the view's filter hook "wpv_filter_query" where you can add/remove the query filter arguments on fly.
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

For example:
- You can add the above code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

add_filter( 'wpv_filter_query', 'func_filter_by_current_post_id_terms', 10, 3 );
 function func_filter_by_current_post_id_terms( $query_args, $setting,$view_id ) {

    if($view_id == 99999) {

         //// adjust original taxonomy slug here
        $taxonomy = 'taxonomy-slug' ;  
          
        /// getting the post id from URL param
        $post_id = $_REQUEST['post-id'];

        $assigned_terms = wp_get_object_terms( $post->ID, $taxonomy , array('fields'=>'slugs'));
  
        $query_args['tax_query'][] = array( 
             array(
            'taxonomy' => $taxonomy,
            'field' => 'slug',
            'terms' =>  $assigned_terms ,
            'operator' => 'IN'
        ));
     
    }
    return $query_args;
}

Where:
- Please replace 99999 with your original view ID
- please adjust the filter code if required as per your requirement