Title: User roles / invoice
Last modified: December 3, 2021

---

# User roles / invoice

 *  Resolved [danne1](https://wordpress.org/support/users/danne1/)
 * (@danne1)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/user-roles-invoice/)
 * Hello!
 * So we need to send invoices for certain groups.
    And I got a snippet to use it
   with user roles, but I cant find in ur actions/filters or hooks how to restrict
   using a specific group/role.
 * Here is an example of the snippet.
 *     ```
       $user = $order->get_user();		
       		if ( ! in_array( 'retailer', (array) $user->roles ) ) { // the 'retailer' user role
       			$allowed = false;
       		}
       ```
   
 * can you help?

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

 *  [Tanue Eugen-Bleck Mbunwo](https://wordpress.org/support/users/eugenbleck/)
 * (@eugenbleck)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/user-roles-invoice/#post-15165693)
 * Hi Danne,
 * Good morning. I trust you are well and safe!
 * With regards to your inquiry, you can use the following snippet to check if the
   user belongs to a group, then proceed to send the invoice based on that condition.
 * Here’s a snippet to check if a user belongs to a group(Foobar for example):
 *     ```
       $is_a_member = false;
       require_once( ABSPATH . 'wp-includes/pluggable.php' );
       if ( $group = Groups_Group::read_by_name( 'Foobar' ) ) {
       $is_a_member = Groups_User_Group::read( get_current_user_id() , $group->group_id );
       }
       ```
   
 * Here are some relevant links:
    * For more examples: [https://docs.itthinx.com/document/groups/api/examples/](https://docs.itthinx.com/document/groups/api/examples/)*
   [https://docs.itthinx.com/document/groups/api/](https://docs.itthinx.com/document/groups/api/)
 * STAY SAFE and I wish you a very productive rest of your day!
    Best, Eugen.
 *  Thread Starter [danne1](https://wordpress.org/support/users/danne1/)
 * (@danne1)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/user-roles-invoice/#post-15169791)
 * Thanks alot!
 * Will try this out, in the meanwhile we can close this 🙂
    Have a great day!

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

The topic ‘User roles / invoice’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups - Memberships and Access Control](https://wordpress.org/plugins/groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/groups/)
 * [Active Topics](https://wordpress.org/support/plugin/groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/groups/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [danne1](https://wordpress.org/support/users/danne1/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/user-roles-invoice/#post-15169791)
 * Status: resolved