Why user loses edit post capabilities or IgnitionDeck Framework special feature

One of the User Role Editor plugin users asked me, why user loses edit posts capabilities assigned to him directly. The issue takes place on a regular basis.
You assign to the user ‘edit_posts’, ‘edit_published_posts’ capabilities with other post’s related capabilities together. But after login and opening ‘Posts’ menu item that user loses his access to the ‘Posts’ menu. If you check his user capabilities after that you will see that he lost all edit post capabilities somehow.

‘How?’ and ‘Why?’.

Are you agree that these are right questions for this moment?
After checking about 15 plugins installed at the client site I discovered that this sudden effect is produced by the ‘IgnitionDeck Framework‘ WordPress plugin. It decides itself if user should be capable to edit posts or he should not.
Look at file idf-wp.php, after line #64. If current user was not meet some special conditions IDF removes from him all edit posts capabilities, from line #64:

if ($pass) {
  idc_add_upload_cap($user);
}
else {
  idc_remove_upload_cap($user);
}

From line #86:

function idc_remove_upload_cap($user) {
	if (!empty($user)) {
		$user->remove_cap('edit_others_pages');
		$user->remove_cap('edit_others_posts');
		$user->remove_cap('edit_pages');
		$user->remove_cap('edit_posts');
		$user->remove_cap('edit_private_pages');
		$user->remove_cap('edit_private_posts');
		$user->remove_cap('edit_published_pages');
		$user->remove_cap('edit_published_posts');
	}
}

If you wish to allow your user to edit posts directly assigning him needed user capabilities you may switch off this code from IDF plugin. Just add this code to the end of your active theme functions.php file:

remove_action('wp', 'idf_add_media_buttons');
Share