{"id":740,"date":"2011-12-19T22:20:48","date_gmt":"2011-12-19T20:20:48","guid":{"rendered":"http:\/\/www.kavdesign.net\/blog\/?p=740"},"modified":"2011-12-19T22:20:48","modified_gmt":"2011-12-19T20:20:48","slug":"allow-member-to-have-access-to-custom-post-type-only-permission-to-only-edit-their-own-posts","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/allow-member-to-have-access-to-custom-post-type-only-permission-to-only-edit-their-own-posts\/","title":{"rendered":"Allow member to have access to custom post type only. Permission to only edit their own posts"},"content":{"rendered":"<p>Here&#8217;s the solution:<\/p>\n<p><a href=\"http:\/\/wordpress.stackexchange.com\/questions\/14553\/allow-member-to-have-access-to-custom-post-type-only-permission-to-only-edit-th\" target=\"_blank\">http:\/\/wordpress.stackexchange.com\/questions\/14553\/allow-member-to-have-access-to-custom-post-type-only-permission-to-only-edit-th<\/a><\/p>\n<p>Which says:<\/p>\n<div>\n<p><em>Use Justin Tadlock&#8217;s plugin &#8220;<a href=\"http:\/\/wordpress.org\/extend\/plugins\/members\/\" rel=\"nofollow\">Members<\/a>&#8220;. It gives you the ability to create new roles and edit existing roles, as well as add custom capabilities. All that work that you&#8217;d have to do can be taken down to a few clicks.<\/em><\/p>\n<p><em>I know you said in your comment on ZaMoose&#8217;s answer that you are &#8216;looking to write the functionality myself so I have full control over everything.&#8217; That&#8217;s missing the whole point of open source software. Justin Tadlock released his plugin so you could use it precisely so you WOULD have complete control over everything.<\/em><\/p>\n<p><em>If you really <strong>really<\/strong> want to reinvent the wheel, potentially wasting hundreds of hours of your own time I can&#8217;t stop you, but you could at least save yourself the trouble and use Tadlock&#8217;s plugin to learn how to do what you want.<\/em><\/p>\n<p><em>Once you have a plugin that does what you want, you&#8217;ll need to change the <code>'map_meta_cap'<\/code> flag to <code>true<\/code> and the <code>'capability_type'<\/code> flag in your post type registration function so that it says something other than &#8216;post&#8217;, &#8216;page&#8217;, or any other &#8216;reserved&#8217; type. Then, duplicate all the capabilities related to posts (e.g. <code>edit_posts<\/code>, <code>edit_others_posts<\/code>, <code>publish_posts<\/code>, etc.), using your capability type instead of posts. Make sure to assign all these permissions to administrators (you won&#8217;t be able to see the post type until you do this), then create your role, mimicking the &#8216;contributor&#8217; role&#8217;s abilities for your post type.<\/em><\/p>\n<p><em>For example, say your capability type was <code>foobars<\/code>, you would want to give &#8216;shop owners&#8217; the <code>edit_foobars<\/code>, <code>delete_foobars<\/code>, and <code>read<\/code> capabilities. That way they can create their own draft foobars, and delete those drafts, but because they don&#8217;t have <code>publish_foobars<\/code> capabilities, they have to submit them for approval. Because they don&#8217;t have <code>edit_published_foobars<\/code>, all modifications to an approved foobar have to be approved.<\/em><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s the solution: http:\/\/wordpress.stackexchange.com\/questions\/14553\/allow-member-to-have-access-to-custom-post-type-only-permission-to-only-edit-th Which says: Use Justin Tadlock&#8217;s plugin &#8220;Members&#8220;. It gives you the ability to create new roles and edit existing roles, as&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/allow-member-to-have-access-to-custom-post-type-only-permission-to-only-edit-their-own-posts\/\">Continue reading<span class=\"screen-reader-text\">Allow member to have access to custom post type only. Permission to only edit their own posts<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9,82],"tags":[230,157,229,232,147,231],"class_list":["post-740","post","type-post","status-publish","format-standard","hentry","category-coding","category-wordpress","tag-access","tag-custom","tag-member","tag-permission","tag-post","tag-type","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=740"}],"version-history":[{"count":1,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/740\/revisions"}],"predecessor-version":[{"id":741,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/740\/revisions\/741"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}