• 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.