Use a url parameter as an input inside my form

This topic contains 2 reply and 2 voices, and was last updated by Sekander Badsha 9 years, 7 months ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
September 4, 2014 at 12:22 pm 26289
Sekander Badsha My product categories are more than 100 hundred(categories,subcategories and sub subcategories). Thus when the user wants to add a new product is very difficult for him to choose the right product category. What is possible is to break the forms one for each main product category. Is there a way though that I can limit down the forms into only one by having preselected from before the product category I want to add the product ? I can use the following code to update a product category with a hidden field function wpuf_update_hidden_product_types($post_id) { function wpuf_update_hidden_categories($post_id) { $cats = $_POST['product_category']; // $cats = htmlspecialchars($_GET["product_category"]); $categories = array_map('intval', explode (',', $cats)); wp_set_object_terms( $post_id, $categories, 'product_cat'); // Optional to clean up the database (deletes the hidden field data after converting it into object terms) delete_post_meta( $post_id, 'product_categories', $_POST['product_categories'] ); } add_action( 'wpuf_add_post_after_insert', 'wpuf_update_hidden_categories' ); add_action( 'wpuf_edit_post_after_update', 'wpuf_update_hidden_categories' ); What I want is to pass the product category on the url e.g mysite.com/add-a-new-product/?product_category=75 I have tried the $_GET command but with no success. I have tried and succeeded to add a fixed metavalue inside a hidden field with the name product_category but I do not want a fixed value but a variable value taken from url. Is there a way I can add a variable value inside a hidden field meta value and how?
September 8, 2014 at 10:27 am 26452
kyriakosdz kyriakosdz

Still Waiting for a reply!!

September 9, 2014 at 12:07 pm 26515
Sekander Badsha Sekander Badsha

Hello kyriakosdz,
If you have lots of categories and sub categories, you can use the Ajax categories. It will show you the parent categories first and will show the child after selecting the parent. But remember, this Ajax only works if the user is logged in.

Viewing 2 Posts - 1 through 2 (of 2 total)