Title: Separate add.php forms for different categories
Last modified: August 31, 2016

---

# Separate add.php forms for different categories

 *  Resolved [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/)
 * I have two types of categories, for which I would like to have separate add.php
   forms for each.. One page will allow users to create an advert for one type of
   category, and a second page will only allow users to create adverts for the other
   category.
 * I have a membership association with two membership levels, each able to post
   an advert to a different category. I can hide the pages using shortcode, but 
   need to effectively predetermine the advert category for each page.
 * Any help gratefully received.
 * [https://wordpress.org/plugins/wpadverts/](https://wordpress.org/plugins/wpadverts/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456750)
 * You actually need two different form schemes not different add.php template files,
   the form scheme you can manipulate using adverts_form_load filter [http://wpadverts.com/documentation/custom-fields/](http://wpadverts.com/documentation/custom-fields/),
   but i am afraid it will not allow you to set predefined category, it will just
   allow to add, edit and remove fields from the form.
 *  Thread Starter [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456753)
 * Thanks for your quick reply.
    I guess I can hide a category on the form scheme,
   which would only allow people to select the categories left available to them,
   that would work. How do I choose which form scheme is loaded?
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456886)
 * I imagine you could have the [adverts_add] on two pages one with ID = 100 and
   the other with ID = 200. When loading the form you can check on which page you
   currently are and based on this remove the category field
 *     ```
       add_filter( "adverts_form_load", "customize_adverts_add" );
   
       function customize_adverts_add( $form ) {
         if( $form['name'] != "advert" ) {
           return $form;
         }
   
         foreach( $form["field"] as $key => $field ) {
           if( is_page( 200 ) && $field["name"] == "advert_category" ) {
               unset( $form["field"][$key] );
           }
         }
   
         return $form;
       }
       ```
   
 *  Thread Starter [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456888)
 * Super, i’ll give that a go, thank you! So you would title the pages “100” and“
   200” in that example?
 *  Thread Starter [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456902)
 * Sorry, silly question – figured out what you meant by page ID and your suggestion
   works. Thank you for your help!
 *  Thread Starter [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456905)
 * Just trying to adapt your code slightly so that instead of removing the category
   field entirely, it hides a category with a specific ID. Is this possible as I’m
   struggling!? Thank you in advance… i promise to make a donation! 🙂
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456923)
 * Try
 *     ```
       add_filter( "adverts_form_load", "customize_adverts_add" );
   
       function customize_adverts_add( $form ) {
         if( $form['name'] != "advert" ) {
           return $form;
         }
   
         foreach( $form["field"] as $key => $field ) {
           if( is_page( 200 ) && $field["name"] == "advert_category" ) {
               $form["field"][$key]["options_callback"] = "my_adverts_taxonomies";
           }
         }
   
         return $form;
       }
   
       function my_adverts_taxonomies() {
   
           $args = array(
               'taxonomy'     => 'advert_category',
               'hierarchical' => true,
               'orderby'       => 'name',
               'order'         => 'ASC',
               'hide_empty'   => false,
               'depth'         => 0,
               'selected' => 0,
               'show_count' => 0,
               'exclude' => array( 1000 )
           );
   
           include_once ADVERTS_PATH . '/includes/class-walker-category-options.php';
   
           $walker = new Adverts_Walker_Category_Options;
           $params = array(
               get_terms( 'advert_category', $args ),
               0,
               $args
           );
   
           return call_user_func_array(array( &$walker, 'walk' ), $params );
       }
       ```
   
 * But replace 1000 with actual Category ID you wish to hide.
 *  Thread Starter [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [10 years ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456925)
 * 🙂 You’re amazing! Thank you – I would have had no idea how to accomplish that!
   
   Great app, great support and will very happily send you a donation for all your
   work. Thank you!
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456939)
 * Sure, no problem :), there is no need for donation, but i would be thankful if
   you could write a short one or two sentence review here [https://wordpress.org/support/view/plugin-reviews/wpadverts](https://wordpress.org/support/view/plugin-reviews/wpadverts)
 *  Thread Starter [domcoutts](https://wordpress.org/support/users/domcoutts/)
 * (@domcoutts)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456945)
 * All done 🙂 thank you again. Was going to send a donation anyway but can’t find
   a way of doing so. You have my full gratitude for all your help.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456961)
 * Thanks! I actually do not have donation link anywhere, but if you would like 
   to make some kind of donation, you can get one of premium add-ons instead [http://wpadverts.com/extensions/](http://wpadverts.com/extensions/),
   that would be a win-win situation :).

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Separate add.php forms for different categories’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * Last activity: [9 years, 12 months ago](https://wordpress.org/support/topic/separate-addphp-forms-for-different-categories/#post-7456961)
 * Status: resolved