-
AuthorPosts
-
September 29, 2015 at 10:05 am #603177
Hello.
We need to restrict user edit access to specific pages and are building some custom functions to control this. We are using the
current_user_can()
function (https://codex.wordpress.org/Function_Reference/current_user_can) and need the capability that grants access to Cornerstone. What is the specific user capability that grants access to Cornerstone?Thanks.
September 29, 2015 at 10:57 am #603261Hi there,
Thanks for writing in! You can select which user role can access Cornerstone Editor from Settings > Cornerstone. See – http://prntscr.com/8lue6w
Hope this helps.
Cheers!
September 29, 2015 at 11:18 am #603299Hi Y’all. Thanks for the info, but we need a more granular answer. All the users will have the same role, but not all will have access to edit all pages. We want to assign access to edit a page (or post or custom post type) via Cornerstone based on individual user and specific posts.
I know that this is not built in to X or Cornerstone, we are developing a custom solution. We just need to know what capability you are assigning to the Roles via the Permissions section of Settings > Cornerstone.
Thanks
September 29, 2015 at 12:43 pm #603447Hey there,
Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.
Thank you for your understanding.
September 30, 2015 at 11:28 am #605021Hi. Thanks for the response.
I’m not requiring any customization, I just need the user capability that is assigned or revoked via the Permissions section of Settings > Cornerstone.
Thanks
September 30, 2015 at 2:07 pm #605240Hi Rob,
We haven’t created a new capability. First, it we store a list of allowed post types. This takes effect regardless of roles. Then we simply check if the current user has one of the roles present. If the user has the
manage_options
role, it supersedes any other roles, but the allowed post types are still taken into consideration. Overall, it’s a very simple permissions system, which we believe covers the vast majority of use cases.That being said, we included a filter for developers who wish to implement something more structured.
First, you’ll need to enable all roles. Next you can add this code to functions.php of a theme, and adjust accordingly.
add_filter( 'cornerstone_allowed_post_types', 'custom_cornerstone_post_type_permissions' ); function custom_cornerstone_post_type_permissions( $post_types ) { $custom = array(); if ( current_user_can( 'custom_cap') ) $custom[] = 'page'; if ( current_user_can( 'another_custom_cap') ) $custom[] = 'post'; return $custom; }
The
$post_types
parameter is an array of post types from the cornerstone settings page.You’ll just need to implement your own logic to manipulate the array of post types as needed.
September 30, 2015 at 2:59 pm #605324Wonderful! Thank you very much!
September 30, 2015 at 3:56 pm #605403You are most welcome 🙂 .
April 20, 2016 at 12:47 pm #892228Just what I was looking for! Creating a website where both posts and pages are to be created and edited with cornerstone, but where only administrator can add and edit both posts and pages and editors can only add and edit posts.
Applies this solution and it works perfectly. Thanks.April 21, 2016 at 12:45 am #893059 -
AuthorPosts