Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Passing a setting to the redirect URL
This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko 6 years, 12 months ago.
- AuthorPosts
- December 8, 2016 at 7:44 pm #11222
Hi
I am attempting to follow your instructions here on how to pass additional parameters to the redirect URL: https://wp-dreams.com/knowledge-base/how-to-add-variables-to-the-redirect-to-url-or-the-show-more-url/
// Use this to change the "redirect to url" parameter add_filter( 'asp_redirect_url', 'asp_add_params_to_url', 1, 10 ); // Use this to change the "show more results url" parameter add_filter( 'asp_show_more_url', 'asp_add_params_to_url', 1, 10 ); function asp_add_params_to_url( $url ) { // Array of param names and values $values = array( "fwp_itemtype" => "MYSETTINGHERE" ); // Merge them together foreach ( $values as $k => $v ) $url .= "&".$k."=".$v; return $url; }
My confusion is how to pass the item_type I have selected in the settings (for example, “event”) to MYSETTINGHERE. Can you clarify.
Many thanks.
-Matthew
Thinking Partners
Red Hook, NYDecember 8, 2016 at 7:48 pm #11223Here’s a screenshot, for clarity sake
Attachments:
You must be logged in to view attached files.December 9, 2016 at 10:51 am #11225Hi,
The field values for checkboxes are passed along in the $_POST request variable. Each fieldset group has a unique name to prevent conflicts. The best was to find the name is by simply using the developer tools, in your case: https://i.imgur.com/esNra6o.png
So the selected items will be in the:
$_POST['aspf1_11']['wpcf-item_type_1']
array.
But the problem is that you won’t be able to add that there, as this is set only after the search is already printed on the page. The only solution is to create some kind of javascript code to change the redirect url on the FORM element.
-
This reply was modified 7 years ago by
Ernest Marcinko.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 12, 2016 at 11:59 pm #11247Okay, thanks for your reply! I will use JavaScript. But in the meantime, WHAT exactly are these instructions for?
Wouldn’t you want parameters appended to the URLs to be dynamic depending upon what the user has selected?
December 13, 2016 at 12:31 pm #11255Hi,
It’s for cases when you want to add static variables based on certian conditions (like current post ID, custom field values, etc..). This is however executed right before the plugin is printed. Dynamically changing the redirection requires javascript, as it’s triggered from the client side (browser), however PHP runs on the server side.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 13, 2016 at 11:21 pm #11270Many thanks for clearing that up and keep up the great work.
December 14, 2016 at 3:30 pm #11272You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This reply was modified 7 years ago by
- AuthorPosts
You must be logged in to reply to this topic.