Title: Exclusion Settings
Last modified: October 4, 2017

---

# Exclusion Settings

 *  Resolved [cronopium](https://wordpress.org/support/users/cronopium/)
 * (@cronopium)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/)
 * I build a shop for B2C clients and B2B clients and use the catalog enquiry for
   disabling prices for B2C.
    In the exclusion definitions I am surprised there 
   is no possibility to use user role for exclusion. If I could use user role for
   exclusion I could configure a automatic process … all clients with b2b user role
   can see the prices and use the order … you only use a user list for exclusion–
   this would need every b2b client put in this list. if you don’t give the possibility
   for user role in backend, maybe you can help me with a code for filtering in 
   the function php – it would be very helpful.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fexclusion-settings%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [DualCube](https://wordpress.org/support/users/dualcube/)
 * (@dualcube)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9559748)
 * Kindly use this code snippet :
 *     ```
       function user_role_exclude_catalog(){
       global $WC_Woocommerce_Catalog_Enquiry;
       $current_user = wp_get_current_user();
       if($WC_Woocommerce_Catalog_Enquiry){
       if(in_array('your_restricted_user_role', $current_user->roles)){
       remove_action('woocommerce_single_product_summary', array($WC_Woocommerce_Catalog_Enquiry->frontend,'add_form_for_enquiry_without_popup'),100);
       remove_action('woocommerce_single_product_summary', array($WC_Woocommerce_Catalog_Enquiry->frontend,'add_form_for_enquiry'),100);
       }else{
       $WC_Woocommerce_Catalog_Enquiry->frontend->init_catalog();
       }
       }
       }
       add_action('init', 'user_role_exclude_catalog', 999);
       ```
   
 * Let us know if you have any further query.
 *  Thread Starter [cronopium](https://wordpress.org/support/users/cronopium/)
 * (@cronopium)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9560405)
 * thank you for the fast solution 🙂
 *  Thread Starter [cronopium](https://wordpress.org/support/users/cronopium/)
 * (@cronopium)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9560896)
 * Hello, if I use this code I lost the dashboard …
    in debug I get this – maybe
   you understand where the problem is:
 * `Fatal error: Uncaught Error: Call to a member function init_catalog() on null
   in /html/wordpress/wp-content/themes/infinity-pro/functions.php:326 Stack trace:#
   0 /html/wordpress/wp-includes/class-wp-hook.php(298): user_role_exclude_catalog(”)#
   1 /html/wordpress/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(
   false, Array) #2 /html/wordpress/wp-includes/plugin.php(453): WP_Hook->do_action(
   Array) #3 /html/wordpress/wp-settings.php(448): do_action(‘init’) #4 /html/wordpress/
   wp-config.php(115): require_once(‘/html/wordpress…’) #5 /html/wordpress/wp-load.
   php(37): require_once(‘/html/wordpress…’) #6 /html/wordpress/wp-admin/admin.php(
   31): require_once(‘/html/wordpress…’) #7 /html/wordpress/wp-admin/post.php(12):
   require_once(‘/html/wordpress…’) #8 {main} thrown in /html/wordpress/wp-content/
   themes/infinity-pro/functions.php on line 326
 *  [DualCube](https://wordpress.org/support/users/dualcube/)
 * (@dualcube)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9561501)
 * Sorry, for this. Kindly use changes the hook name `init` to `wp` and let us know
   whether this fixed the error.
 * Awaiting for your confirmation.
 *  Thread Starter [cronopium](https://wordpress.org/support/users/cronopium/)
 * (@cronopium)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9563222)
 * After change I get the Dashboard but don’t products or woo commerce orders anymore
 *     ```
       function user_role_exclude_catalog(){
       global $WC_Woocommerce_Catalog_Enquiry;
       $current_user = wp_get_current_user();
       if($WC_Woocommerce_Catalog_Enquiry){
       if(in_array('your_restricted_user_role', $current_user->roles)){
       remove_action('woocommerce_single_product_summary', array($WC_Woocommerce_Catalog_Enquiry->frontend,'add_form_for_enquiry_without_popup'),100);
       remove_action('woocommerce_single_product_summary', array($WC_Woocommerce_Catalog_Enquiry->frontend,'add_form_for_enquiry'),100);
       }else{
       $WC_Woocommerce_Catalog_Enquiry->frontend->wp_catalog();
       }
       }
       }
       add_action('wp', 'user_role_exclude_catalog', 999);
       ```
   
 * The error code:
 * `Fatal error: Uncaught Error: Call to a member function wp_catalog() on null 
   in /html/wordpress/wp-content/themes/infinity-pro/functions.php:306 Stack trace:#
   0 /html/wordpress/wp-includes/class-wp-hook.php(298): user_role_exclude_catalog(
   Object(WP)) #1 /html/wordpress/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(
   NULL, Array) #2 /html/wordpress/wp-includes/plugin.php(515): WP_Hook->do_action(
   Array) #3 /html/wordpress/wp-includes/class-wp.php(746): do_action_ref_array('
   wp', Array) #4 /html/wordpress/wp-includes/functions.php(955): WP->main(Array)#
   5 /html/wordpress/wp-admin/includes/post.php(1072): wp(Array) #6 /html/wordpress/
   wp-admin/includes/class-wp-posts-list-table.php(142): wp_edit_posts_query() #
   7 /html/wordpress/wp-admin/edit.php(180): WP_Posts_List_Table->prepare_items()#
   8 {main} thrown in /html/wordpress/wp-content/themes/infinity-pro/functions.php
   on line 306`
 *  [DualCube](https://wordpress.org/support/users/dualcube/)
 * (@dualcube)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9565297)
 * Just change the hook name and not the function name init_catalog() to wp_catalog().
 * For further assistance please see this screenshot : [https://drive.google.com/a/dualcube.com/file/d/0Bx3S5WbEjHvpWE10aHhFT3NlZXM/view?usp=drivesdk](https://drive.google.com/a/dualcube.com/file/d/0Bx3S5WbEjHvpWE10aHhFT3NlZXM/view?usp=drivesdk)
 *  Thread Starter [cronopium](https://wordpress.org/support/users/cronopium/)
 * (@cronopium)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9565660)
 * I’m so sorry…
    of course – first I only did change this but Error again. After
   I tried other. Then I did try again to exclude a standard role ‘subscriber’ instead
   of my own but the same …
 *     ```
       //* Catalog Enquiry user role
       function user_role_exclude_catalog(){
       global $WC_Woocommerce_Catalog_Enquiry;
       $current_user = wp_get_current_user();
       if($WC_Woocommerce_Catalog_Enquiry){
       if(in_array('subscriber', $current_user->roles)){
       remove_action('woocommerce_single_product_summary', array($WC_Woocommerce_Catalog_Enquiry->frontend,'add_form_for_enquiry_without_popup'),100);
       remove_action('woocommerce_single_product_summary', array($WC_Woocommerce_Catalog_Enquiry->frontend,'add_form_for_enquiry'),100);
       }else{
       $WC_Woocommerce_Catalog_Enquiry->frontend->init_catalog();
       }
       }
       }
       add_action('wp', 'user_role_exclude_catalog', 999);
       ```
   
 * `Fatal error: Uncaught Error: Call to a member function init_catalog() on null
   in /html/wordpress/wp-content/themes/infinity-pro/functions.php:306 Stack trace:#
   0 /html/wordpress/wp-includes/class-wp-hook.php(298): user_role_exclude_catalog(
   Object(WP)) #1 /html/wordpress/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(
   NULL, Array) #2 /html/wordpress/wp-includes/plugin.php(515): WP_Hook->do_action(
   Array) #3 /html/wordpress/wp-includes/class-wp.php(746): do_action_ref_array('
   wp', Array) #4 /html/wordpress/wp-includes/functions.php(955): WP->main(Array)#
   5 /html/wordpress/wp-admin/includes/post.php(1072): wp(Array) #6 /html/wordpress/
   wp-admin/includes/class-wp-posts-list-table.php(142): wp_edit_posts_query() #
   7 /html/wordpress/wp-admin/edit.php(180): WP_Posts_List_Table->prepare_items()#
   8 {main} thrown in /html/wordpress/wp-content/themes/infinity-pro/functions.php
   on line 306`
 *  Thread Starter [cronopium](https://wordpress.org/support/users/cronopium/)
 * (@cronopium)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9571253)
 * do you have no other idea? it would be so helpful if I could work with user role…
 *  [DualCube](https://wordpress.org/support/users/dualcube/)
 * (@dualcube)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9584003)
 * do a woocommerce-catalog-enquiry plugin active check within function before the
   codes and let us know the result.
 *  [bpamedia](https://wordpress.org/support/users/bpamedia/)
 * (@bpamedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9602890)
 * Thanks for help, but unfortunately me english is not good enough – I’m not really
   understanding what I i have to do to get the result you need.
 *  [bpamedia](https://wordpress.org/support/users/bpamedia/)
 * (@bpamedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9607927)
 * Just now I see another Plugin with the same functionality has the role exclusion
   as standard (seems for me it is the much better way because it is not practicable
   a lot of customers exclude by hand) …
    but I would like to go on with your plugin–
   it works for me, I’m only missing the role excusing. maybe you will integrate
   in future in your plugin?
 *  [DualCube](https://wordpress.org/support/users/dualcube/)
 * (@dualcube)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9621866)
 * Hi [@bpamedia](https://wordpress.org/support/users/bpamedia/), thanks for getting
   in touch with us.
 * We have forwarded this request to our development team, they will take a further
   decision over this.

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

The topic ‘Exclusion Settings’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-catalog-enquiry/assets/icon-256x256.png?rev=
   3283706)
 * [CatalogX - Catalog Mode, Enquiry & Quotes for WooCommerce](https://wordpress.org/plugins/woocommerce-catalog-enquiry/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-catalog-enquiry/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-catalog-enquiry/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-catalog-enquiry/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-catalog-enquiry/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-catalog-enquiry/reviews/)

 * 12 replies
 * 3 participants
 * Last reply from: [DualCube](https://wordpress.org/support/users/dualcube/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/exclusion-settings/#post-9621866)
 * Status: resolved