Title: Plugin Not Compatible With Limit Posts Plugin
Last modified: August 31, 2016

---

# Plugin Not Compatible With Limit Posts Plugin

 *  Resolved [Liltiger](https://wordpress.org/support/users/liltiger/)
 * (@liltiger)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/plugin-not-compatible-with-limit-posts-plugin/)
 * Hi There!
 * First off, I just want to thank you for your awesome plugin! I’m bummed to find
   out that it’s not working with the Limit Posts plugin, by Plugin Central, when
   I create a new user role with your plugin.
 * For example: I’ve added the new user role, contributor_basic with your plugin.
   The Limit Posts plugin does not limit the posts for that role. However, when 
   I add a user role manually in the functions file using: `$result = add_role( '
   contributor_basic', __( 'Contributor Basic' ), array( ) );` the Limit Posts plugin
   does its job.
 * Is there a way to make the Limit Posts plugin recognize new user roles created
   with this plugin? I’d love to continue using both!
 * Best Regards
 * [https://wordpress.org/plugins/user-role-editor/](https://wordpress.org/plugins/user-role-editor/)

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

 *  Plugin Author [Vladimir Garagulya](https://wordpress.org/support/users/shinephp/)
 * (@shinephp)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/plugin-not-compatible-with-limit-posts-plugin/#post-7097174)
 * Hi,
 * User Role Editor uses the same WordPress API to add new roles, so there is no
   differences here.
    “Limit Posts” author supposes that user role ID and user role
   name are the same. It stores at the plugins settings page role name, but when
   tries to apply the rule get the role ID of current user and just converts it’s
   1st letter to the uppercase.
 *     ```
       private function getCurrentUserRole(){
       	global $current_user;
   
       	$userRole = $current_user->roles;
   
       	return ucfirst($userRole[0]);
       }
       ```
   
 * So for the ‘Contributor Copy (contributor-copy)’ role, which I tested, the automatically
   build name ‘Contributor-copy’ will never match with the real one ‘Contributor
   Copy’, which I tested. The rule is not applied for this case for the custom roles
   created with User Role Editor.
 * To get a valid role name for a role ID a developer should take it from the $wp_roles
   global instead.
 *  Thread Starter [Liltiger](https://wordpress.org/support/users/liltiger/)
 * (@liltiger)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/plugin-not-compatible-with-limit-posts-plugin/#post-7097243)
 * Hi Vladimir,
 * Thanks for the prompt response and for investigating this. I REALLY appreciate
   your help!
 * I don’t fully understand $wp_roles, but with some help and your direction, we
   modified the code below to make it work with the user roles I created:
 *     ```
       //filter out any rules not for a user role
       	private function filterRulesForUserRole($inputRules, $userRole){
       		$filteredRules = array();
   
       		foreach($inputRules['rule'] as $rule){
       			$userOrRole = $this->getUserOrRole($rule);
       			if($userOrRole != 'role'){
       				$filteredRules[] = $rule;
       			}
       			else{
       				<strong>if((strtoupper(str_replace('_', ' ', $rule['role'])) == strtoupper(str_replace('_', ' ', $userRole))) || $rule['role'] == 'ALL'){</strong>
       					$filteredRules[] = $rule;
       				}
       			}
       		}
   
       		return $filteredRules;
       	}
       ```
   

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

The topic ‘Plugin Not Compatible With Limit Posts Plugin’ is closed to new replies.

 * ![](https://ps.w.org/user-role-editor/assets/icon-256x256.jpg?rev=1020390)
 * [User Role Editor](https://wordpress.org/plugins/user-role-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-role-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-role-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/user-role-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-role-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-role-editor/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Liltiger](https://wordpress.org/support/users/liltiger/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/plugin-not-compatible-with-limit-posts-plugin/#post-7097243)
 * Status: resolved