Skip to content

Conversation

@adekbadek
Copy link
Member

@adekbadek adekbadek commented Apr 14, 2025

All Submissions:

Changes proposed in this Pull Request:

Adjusts caps, so the unavailable menu options are hidden for non-admins.

Dependent on Automattic/newspack-plugin#3920

How to test the changes in this Pull Request:

  1. On trunk,
  2. Create a new author user and log in as them
  3. Observe the Network → Subscriptions and → Orders admin menus are displayed
image
  1. Switch to this branch, observe these items are not displayed
  2. Log in a the site administrator, confirm you can access these and other Network page via the admin menu

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@adekbadek adekbadek requested a review from a team as a code owner April 14, 2025 10:00
@adekbadek adekbadek force-pushed the fix/subs-orders-caps branch from dbe4287 to d8dfad7 Compare April 14, 2025 10:10
Copy link
Member

@naxoc naxoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this locally. It does indeed make the menu item go away, but it is also gone for my admin user. Should the capability be added/registered somewhere for it to work?

'capabilities' => [
'create_posts' => 'not_a_real_capability', // Set to a fake capability to remove "add new" button.
'create_posts' => 'not_a_real_capability', // Set to a fake capability to remove "add new" button.
'edit_posts' => \Newspack_Network\Admin::REQUIRED_CAPABILITY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it's the same namespace, so \Network_Network\ is not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed in aca3096

@adekbadek
Copy link
Member Author

I tested this locally. It does indeed make the menu item go away, but it is also gone for my admin user. Should the capability be added/registered somewhere for it to work?

Ah, that's true. This will depend on Automattic/newspack-plugin#3920, then, when it's merged.

@adekbadek adekbadek marked this pull request as draft April 15, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants