{"action":"created","issue":{"url":"https://api.github.com/repos/woothemes/woocommerce/issues/9309","labels_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9309/labels{/name}","comments_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9309/comments","events_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9309/events","html_url":"https://github.com/woothemes/woocommerce/issues/9309","id":110339206,"number":9309,"title":"Administrator with Sub-role of Customer loses access to Posts Admin Menu","user":{"login":"garrett-eclipse","id":8726005,"avatar_url":"https://avatars.githubusercontent.com/u/8726005?v=3","gravatar_id":"","url":"https://api.github.com/users/garrett-eclipse","html_url":"https://github.com/garrett-eclipse","followers_url":"https://api.github.com/users/garrett-eclipse/followers","following_url":"https://api.github.com/users/garrett-eclipse/following{/other_user}","gists_url":"https://api.github.com/users/garrett-eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/garrett-eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garrett-eclipse/subscriptions","organizations_url":"https://api.github.com/users/garrett-eclipse/orgs","repos_url":"https://api.github.com/users/garrett-eclipse/repos","events_url":"https://api.github.com/users/garrett-eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/garrett-eclipse/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-07T23:24:10Z","updated_at":"2015-10-08T17:40:46Z","closed_at":"2015-10-08T09:39:34Z","body":"Hello,\r\n\r\nDon't ask me why my administrator got a sub-role of customer but when an administrator has a customer role on them they then lose access to the backend menu items for 'All Posts' and 'Add New' under posts. They can access pages just not posts or anything that has a posts capability setting such as a custom post type.\r\n\r\nWould have figured the admininistrator role would add the capabilities rather than the customer role blocking capabilities.\r\n\r\nThoughts?\r\nThanks\r\nP.S. I've removed the role just wanted to raise as I figured it was a bug that the customer role blocks the edit_posts capability even is they also have a higher level role applied to them."},"comment":{"url":"https://api.github.com/repos/woothemes/woocommerce/issues/comments/146634435","html_url":"https://github.com/woothemes/woocommerce/issues/9309#issuecomment-146634435","issue_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9309","id":146634435,"user":{"login":"garrett-eclipse","id":8726005,"avatar_url":"https://avatars.githubusercontent.com/u/8726005?v=3","gravatar_id":"","url":"https://api.github.com/users/garrett-eclipse","html_url":"https://github.com/garrett-eclipse","followers_url":"https://api.github.com/users/garrett-eclipse/followers","following_url":"https://api.github.com/users/garrett-eclipse/following{/other_user}","gists_url":"https://api.github.com/users/garrett-eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/garrett-eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garrett-eclipse/subscriptions","organizations_url":"https://api.github.com/users/garrett-eclipse/orgs","repos_url":"https://api.github.com/users/garrett-eclipse/repos","events_url":"https://api.github.com/users/garrett-eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/garrett-eclipse/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T17:40:46Z","updated_at":"2015-10-08T17:40:46Z","body":"Hi @mikejolley \r\n\r\nThat's actually not correct, a user has a primary role and can have multiple sub-roles. See add_role to add additional roles, set_role replaces all roles with one primary role.\r\nhttps://codex.wordpress.org/Class_Reference/WP_User#add_role.28_.24role_.29\r\n\r\nSo the administrator can have a primary role of Administrator with sub-roles of Customer, etc. As is my case.\r\n\r\nFrom the default WP user edit page you can only set the primary role, however you can programatically add additional roles through WP_User::add_role function. Or if you opt to install a role manager such as [WPFront User Role Editor](https://wordpress.org/plugins/wpfront-user-role-editor/) a gui interface is introduced to the user edit page to manage sub-roles;\r\n![screen shot 2015-10-08 at 9 36 12 am](https://cloud.githubusercontent.com/assets/8726005/10373090/11edda4a-6da0-11e5-8538-a60bc11948b9.png)\r\n\r\nIf this wasn't the case then plugins like Buddypress wouldn't be able to operate as they require a sub-role for their Forum Role (Keymaster, Moderator, Participant, etc.)\r\n\r\nSo the admin isn't actually added as a customer they've just had customer added as a sub-role through the WP_User::add_role function. And with primary and sub-roles standardly capabilities are simply added to the user but in this case they appear to be detracted when the customer is applied as a sub-role.\r\n\r\nLooking into the Woocommerce plugin and the customer role it appears that rather than adding capabilities it actually removes the edit_posts and delete_posts capabilities by setting them to false;\r\n```php\r\n\t\t// Customer role\r\n\t\tadd_role( 'customer', __( 'Customer', 'woocommerce' ), array(\r\n\t\t\t'read' \t\t\t\t\t\t=> true,\r\n\t\t\t'edit_posts' \t\t\t\t=> false,\r\n\t\t\t'delete_posts' \t\t\t\t=> false\r\n\t\t) );\r\n```\r\nThis is in woocommerce/includes/class-wc-install.php on line 483\r\n\r\nSo to me Woocommerce has their customer role set-up to remove capabilities rather than the standard approach of only adding needed capabilities. Is there a reason for this? I amended woo on my instance and re-installed to have the customer role only add the read capability and not remove any capabilities which corrects the issue allowing the admin to have a sub-role of customer which is useful as it indicate they've made purchases through the website.\r\n\r\nAmended code:\r\n```php\r\n\t\t// Customer role\r\n\t\tadd_role( 'customer', __( 'Customer', 'woocommerce' ), array(\r\n\t\t\t'read' \t\t\t\t\t\t=> true\r\n\t\t) );\r\n```\r\n\r\nLet me know your thoughts as I don't foresee any conflicts or issues caused by this change as users with only the customer role won't have the edit_posts or delete_posts capabilities still it just means if this is a sub-role on a user that the capabilities aren't disabled/denied.\r\n\r\nThanks"}}