Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #603177

    Rob D
    Participant

    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.

    #603261

    Rupok
    Member

    Hi 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!

    #603299

    Rob D
    Participant

    Hi 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

    #603447

    Rupok
    Member

    Hey 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.

    #605021

    Rob D
    Participant

    Hi. 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

    #605240

    Alexander
    Keymaster

    Hi 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.

    #605324

    Rob D
    Participant

    Wonderful! Thank you very much!

    #605403

    Prasant Rai
    Moderator

    You are most welcome 🙂 .

    #892228

    cabmos
    Participant

    Just 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.

    #893059

    Rupok
    Member

    You are welcome @cabmos

    Glad that it helped. Feel free to let us know if you face any other issue. We’ll be happy to assist you.

    Thanks for using X.

    Cheers!