{"id":11736,"date":"2024-10-28T14:57:30","date_gmt":"2024-10-28T12:57:30","guid":{"rendered":"https:\/\/creativethemes.com\/blocksy\/?post_type=documentation&#038;p=11736"},"modified":"2024-11-07T19:33:09","modified_gmt":"2024-11-07T17:33:09","slug":"restrict-custom-code-snippets-extension-per-user-role","status":"publish","type":"documentation","link":"https:\/\/creativethemes.com\/blocksy\/docs\/code-snippets\/restrict-custom-code-snippets-extension-per-user-role\/","title":{"rendered":"Restrict &#8220;Custom Code Snippets&#8221; extension per user role"},"content":{"rendered":"\n<p>In case that you wish to restrict the usage of the <a href=\"https:\/\/creativethemes.com\/blocksy\/docs\/extensions\/custom-code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Custom Code Snippets extension<\/a> per user role, this handy PHP filter should be able to help.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter(\n\t'blocksy:capabilities:wp_capability',\n\tfunction ($capability, $scope, $scope_details) {\n\t\tif ($scope === 'ext_code_snippets_fields') {\n\t\t\treturn 'manage_options';\n\t\t}\n\n\t\treturn $capability;\n\t},\n\t10,\n\t3\n);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In case that you wish to restrict the usage of the Custom Code Snippets extension per user role, this handy PHP filter should be able to help.<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"doc_categories":[125],"class_list":["post-11736","documentation","type-documentation","status-publish","hentry","doc_categories-code-snippets"],"blocksy_meta":{"docs_item_badge":"PRO","styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"acf":[],"_links":{"self":[{"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/documentation\/11736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/types\/documentation"}],"author":[{"embeddable":true,"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/comments?post=11736"}],"version-history":[{"count":4,"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/documentation\/11736\/revisions"}],"predecessor-version":[{"id":11798,"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/documentation\/11736\/revisions\/11798"}],"wp:attachment":[{"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/media?parent=11736"}],"wp:term":[{"taxonomy":"doc_categories","embeddable":true,"href":"https:\/\/creativethemes.com\/blocksy\/wp-json\/wp\/v2\/doc_categories?post=11736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}