Get Users by roles for organic groups drupal7
Try this if it works for you.call this function with user_role id and group id as parameter.

    function get_users_on_role_and_group_basis($rid, $gid) {
      $users = entity_load('user'); 
      foreach($users as $user) {
         if(is_array($user-&gt;og_user_node)) {
           if (array_key_exists($rid, $user-&gt;roles)) {
             foreach($user-&gt;og_user_node['und'] as $key=&gt;$values) {
               if(in_array($gid,$values)) {
                 $get_user[] = $user; 
                }
            }    
          }
        }        
      } if(isset($get_user)) {
          return $get_user;
        }else {
        return 0;
      }
    }