• Resolved danne1

    (@danne1)


    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)
  • 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/

    STAY SAFE and I wish you a very productive rest of your day!
    Best,
    Eugen.

    Thread Starter danne1

    (@danne1)

    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.