Specific Component permission

Hi,

I made a component, I want to give an editor permission to use it, and for others not to. I’ve looked in Cornerstone Permissions, where I can control access to the elements, but I can’t find my Component in there.

Should this be possible? Bill.

Hey Bill,

Thanks for reaching out!

Regretfully, it is not possible to set permission to specific components.

I tested the config of elements. If I switch of all elements, I can still add a Section, Row and Columns into a page.

But I see I can hide (or show) all Components.

I think I see a way forward. Thanks Bill.

Here’s another thing that I don’t understand.

  • I used the ‘toggle all’ to switch off ALL elements
  • I then enabled, Section, Row and Column
  • I enabled the Components element, so my one Component shows up

This is for the Editor Role, I saved these settings, and logged in as an Editor. When I command-click the “+” to add an element at the top level, this is what I’m offered:

  • Good: Row, Section, AGS Image and Text
  • Bad: all the rest - some of these things don’t exist in the Elements section of settings

e.g. Where does “Posts (Magazine)” come from? “AGS Image and Text” is the one component I made.

I’d like to understand, My goal is to offer an end-user a minimal set of core elements, and then a set of components from which they can build pages or posts.

Many thanks, Bill.

Hello Bill,

Thank you for the inquiry.

We can’t reproduce the same issue on our end. Toggling permission for the builder elements works as expected. Did you update the changes in the Cornerstone > Settings after toggling the permissions for the elements?

Please provide the admin and editor login details in the secure note so that we can check the issue.

Kind regards.

I’ve added a secure note. I’ve been testing on a 2nd site. The trigger for all the elements above to appear, is to enable the Row element for the editor. Before that the permissions seem to behave normally, ish.

I think with Row enabled, any element which is based on a Row appears in the element list. Including the ones which aren’t even in the Element permissions such as

With Row Disabled:

With Row Enabled:

This isn’t good at all. I don’t want to expose all these elements to an end user, just the Section, Div, Row, Col and Components.

The “AGS Alert Row” is a component based on a Row, hence it appears when Row is enabled. But it can still be used with Row disabled via the Component element.

Try it in the site above - you might need to create an Editor account to see the results. This is a Dev site and quite plain, so feel free to experiment.

Thanks, Bill.

Thank you for the clarification.

Unfortunately, as @marc_a mentioned above, you can only toggle the permission for specific elements, not components. This limitation also applies to exported components.

Thank you for your understanding.

Hi @Ismael

Are you saying that by enabling the Row element - all that other stuff appears? This is my question.

It’s very unhelpful, none of those composite elements appear in the Cornerstone permissions.

I accept I can’t permission a component, but I don’t accept that all those other elements appear, just because I enabled Row for the Editor role.

Why does Cornerstone behave this way?

Thanks, Bill.

Thank you for the update.

Yes, that’s how it works. The AGS Alert Row is an exported Row component, so it won’t display when the current user doesn’t have permission to see Row elements. However, you can still add the component using the Components element.

but I don’t accept that all those other elements appear, just because I enabled Row for the Editor role.

Which other elements are you referring to? When we toggle the Row permission for Administrators, only the AGS Raw Component is affected.

Can you see the long screenshot above? All those elements are available to an Editor login, when you enable the Row element. The AGS Row I’m fine with, I get it. It’s what happens when you enable the Row element that’s taxing me. There is an Editor account in that website, feel free to reset the password, login as the Editor, toggle the Row element on and off, and see what’s showing up for that Editor account inside the Cornerstone page editor.

Bill.

The elements such as Looper List and Posts List are prefab elements, which relies on the Row element. They cannot be toggled in the Permissions > Elements panel, same as the AGS Row Component.

We’ll forward this thread to our channel.

Thank you for your patience.

ok, at least we’re agreeing on what’s happening.

What I’d hoped, was to provide an Editor or Contributor with a limited set of elements and components, such that they can edit pages for themselves. But, given the above, this doesn’t seem viable.

This means sadly relying on the WP Block Editor which means developing a pile of CSS to style those blocks and customise them if needed, for the end user. I’d really like to keep all this within Pro if possible.

It would also be good, to be able to clone permissions from Editor to Contributor for instance, whereas at the moment it’s all manual clicks.

I’ll leave it for your Dev discussions with Charlie :wink:

Best wishes, Bill

Hey Bill,

You’re most welcome!

We had a brief discussion about this and came up with a potential solution for your use-case. You can add this code to the functions.php file to unregister the prefab elements for the Editor role

add_action('cs_register_prefab_elements', function() {
    if (!is_user_logged_in()) {
        return;
    }

    $user = wp_get_current_user();
    $roles = (array) $user->roles;

    if (!in_array('editor', $roles)) {
        return;
    }

    $elements_to_unregister = [
        ['group' => 'post', 'element' => 'terms-cloud'],
        ['group' => 'post', 'element' => 'terms-minimal'],
        ['group' => 'post', 'element' => 'terms-column'],
        ['group' => 'post', 'element' => 'posts-tiles'],
        ['group' => 'post', 'element' => 'posts-minimal'],
        ['group' => 'post', 'element' => 'posts-list'],
        ['group' => 'post', 'element' => 'posts-magazine'],
        ['group' => 'dynamic', 'element' => 'looper-list-baseline'],
        ['group' => 'dynamic', 'element' => 'looper-list-centered'],
        ['group' => 'content', 'element' => 'static-list-baseline'],
        ['group' => 'content', 'element' => 'static-list-centered']
    ];

    foreach ($elements_to_unregister as $element) {
        cs_unregister_prefab_element($element['group'], $element['element']);
    }
}, 10);

Let us know the result.

Thank you for your patience.