Title: multi role support
Last modified: January 8, 2017

---

# multi role support

 *  [iding](https://wordpress.org/support/users/iding/)
 * (@iding)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/multi-role-support/)
 * had to make this change to your plugin to do the job for me, alright plugin over
   all.
    i’d appreciate if you consider this change to the next version so i’d gladly
   get back to using the original plugin
 *     ```
       			//check limit by role
       			global $wp_roles;
       			$roles = $this->balp_get_current_user_role();
       			foreach($roles as $role):
       				$current_role = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;
       				$rules_BY_roles = $this->get_sub_array($options['rules'],'role',$current_role);
       				if ($rules_BY_roles){
       					foreach((array)$rules_BY_roles as $ke => $arr){
       						if ($arr['post_type'] == $type || $arr['post_type'] == "any"){
       							//$count_posts = get_posts(array('author'=>$user_id,'post_type' => $type,'post_status' => $arr['status'],'fields' => 'ids'));
       							$ptype = ($arr['post_type'] == 'any')? "IN ('".implode("', '",get_post_types('', 'names')). "')" : " = '".$arr['post_type']."'";
       							$time = (isset($arr['time_span']) && $arr['time_span'] != "FOREVER" ) ? " AND TIMEDIFF(NOW(), post_date) < '".$arr['time_span']."'" : "";
       							$pstatus = ($arr['status'] == 'any') ? "IN ('publish', 'pending', 'draft', 'future', 'private', 'trash')": " = '".$arr['status']."'";
       							$count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status ". $pstatus ." AND post_author = $user_id AND post_type $ptype".$time);
       							$count = apply_filters('bapl_Count_filter', $count,$arr, $user_id);
       							if($count >= $arr['limit']){
       								if ($use_m)
       									$this->current_message = $arr['message'];
       								return true;
       							}
       						}
       					}
       				}
       			endforeach;
   
       		//get user role
       		public function balp_get_current_user_role() {
       			$current_user = wp_get_current_user();
       			return $roles = $current_user->roles;
       		}
       ```
   

The topic ‘multi role support’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bainternet-posts-creation-limits_ffffff.
   svg)
 * [Bainternet Posts Creation Limits](https://wordpress.org/plugins/bainternet-posts-creation-limits/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bainternet-posts-creation-limits/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/)
 * [Active Topics](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [iding](https://wordpress.org/support/users/iding/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/multi-role-support/)