Skip to content

Caps for RSS Feeds#3908

Merged
adekbadek merged 7 commits intotrunkfrom
feat/granular-permissions
Jun 20, 2025
Merged

Caps for RSS Feeds#3908
adekbadek merged 7 commits intotrunkfrom
feat/granular-permissions

Conversation

@adekbadek
Copy link
Copy Markdown
Member

@adekbadek adekbadek commented Apr 11, 2025

All Submissions:

Changes proposed in this Pull Request:

Adds fine-grained capability control to RSS Feeds. This is a first step (and a POC) in granular capability controls to more areas of Newspack.
Before, RSS Feeds CPT inherited from the regular post capabilities, so an administrator would have to allow a user to edit all posts if they wanted them to edit RSS Feeds.

How to test the changes in this Pull Request:

  1. Confirm that as an Editor and as an Admin, you can still manage RSS Feeds
  2. Install capability-manager-enhanced plugin
  3. Go to Capabilities → Roles and add a new role
  4. In Capabilities → Capabilities edit the role and give it Posts -> Edit* cap and all caps in RSS Feeds:
image
  1. Also add Admin → Read capability
image
  1. Create a new user with this role
  2. Log in as the user and observe that you cannot see any existing posts, but you can manage RSS Feeds

* WC will mess with admin login for users without edit_posts cap

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 added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 11, 2025
@adekbadek adekbadek requested a review from a team as a code owner April 11, 2025 13:02
@adekbadek adekbadek changed the title Feat/granular permissions Caps for RSS Feeds Apr 11, 2025
@adekbadek adekbadek mentioned this pull request Apr 15, 2025
6 tasks
Copy link
Copy Markdown
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

Not sure if this is related to these changes or the capability-manager-enhanced plugin, but a user with these capabilities can't access the main dashboard page, resulting in an error screen immediately after logging in:

Screenshot 2025-05-14 at 10 34 25 AM

If I paste the /wp-admin/edit.php?post_type=partner_rss_feed URL directly into the browser, I can access this page and I also have access to some other menu items. Most of these are probably tied to the edit_posts capability, however because the user lacks edit_others_posts most of the features within these menu items are unusable.

Screenshot 2025-05-14 at 10 32 22 AM

@adekbadek
Copy link
Copy Markdown
Member Author

Admin → Read capability was missing.

image

I've updated the instructions.

@adekbadek adekbadek requested a review from dkoo May 29, 2025 09:51
Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

Working as described!

It's unfortunate that we have to call current_user_can( get_post_type_object( $post_type )->cap->edit_others_posts ) instead of the simpler current_user_can( 'edit_others_posts' ) for these entities now.

Would it make sense for \Newspack\Capabilities to provide a more straightfoward way to get that value?

@adekbadek
Copy link
Copy Markdown
Member Author

Would it make sense for \Newspack\Capabilities to provide a more straightfoward way to get that value?

Good idea, added Capabilities::current_user_can method

@adekbadek adekbadek requested a review from miguelpeixe June 16, 2025 08:37
Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

💯

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Jun 16, 2025
@adekbadek adekbadek merged commit 2620c54 into trunk Jun 20, 2025
8 checks passed
@adekbadek adekbadek deleted the feat/granular-permissions branch June 20, 2025 07:14
@github-actions
Copy link
Copy Markdown

Hey @adekbadek, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Jul 3, 2025
# [6.12.0-alpha.1](v6.11.2...v6.12.0-alpha.1) (2025-07-03)

### Bug Fixes

* **menu:** don't hide sponsors menu if the user can't see the newspack dashboard ([#4041](#4041)) ([f988bd2](f988bd2))
* saving name when registering user ([#4050](#4050)) ([498028e](498028e))
* **woocommerce-memberships:** prevent membership expiry if there's another active subscription ([#4009](#4009)) ([6b42cbd](6b42cbd))

### Features

* **capabilities:** add caps for RSS Feeds ([#3908](#3908)) ([2620c54](2620c54))
* **collections:** add hierarchical fields ([#4051](#4051)) ([3f5a704](3f5a704))
* **collections:** allow overriding "collection" names and slugs ([#4033](#4033)) ([f5523b0](f5523b0))
* **collections:** support multiple CTAs in collections meta ([#4049](#4049)) ([d445444](d445444))
* modal checkout for My Account's reorders ([#3988](#3988)) ([fd347bc](fd347bc))
* **my-account:** subscription payment notice ([#4029](#4029)) ([4b78d7f](4b78d7f))
* **rss:** Custom Tracking snippet ([#4047](#4047)) ([2e682c5](2e682c5))
* **rss:** Hooks extending RSS ([#4055](#4055)) ([da97ff4](da97ff4))
* **rss:** Skip non-distributable images ([#4052](#4052)) ([9fdfe78](9fdfe78))
* show "deleted" label on segments if list, subscription, or plan was deleted [NPPM-2031] ([#4021](#4021)) ([4dec8bb](4dec8bb))
* **woocommerce:** rename WooCommerce Payments to WooPay ([#4048](#4048)) ([1528cad](1528cad))
@matticbot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.12.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jul 14, 2025
# [6.12.0](v6.11.3...v6.12.0) (2025-07-14)

### Bug Fixes

* **menu:** don't hide sponsors menu if the user can't see the newspack dashboard ([#4041](#4041)) ([f988bd2](f988bd2))
* saving name when registering user ([#4050](#4050)) ([498028e](498028e))
* **woocommerce-memberships:** prevent membership expiry if there's another active subscription ([#4009](#4009)) ([6b42cbd](6b42cbd))

### Features

* **capabilities:** add caps for RSS Feeds ([#3908](#3908)) ([2620c54](2620c54))
* **collections:** add hierarchical fields ([#4051](#4051)) ([3f5a704](3f5a704))
* **collections:** allow overriding "collection" names and slugs ([#4033](#4033)) ([f5523b0](f5523b0))
* **collections:** support multiple CTAs in collections meta ([#4049](#4049)) ([d445444](d445444))
* modal checkout for My Account's reorders ([#3988](#3988)) ([fd347bc](fd347bc))
* **my-account:** subscription payment notice ([#4029](#4029)) ([4b78d7f](4b78d7f))
* **rss:** Custom Tracking snippet ([#4047](#4047)) ([2e682c5](2e682c5))
* **rss:** Hooks extending RSS ([#4055](#4055)) ([da97ff4](da97ff4))
* **rss:** Skip non-distributable images ([#4052](#4052)) ([9fdfe78](9fdfe78))
* show "deleted" label on segments if list, subscription, or plan was deleted [NPPM-2031] ([#4021](#4021)) ([4dec8bb](4dec8bb))
* **woocommerce:** rename WooCommerce Payments to WooPay ([#4048](#4048)) ([1528cad](1528cad))
@matticbot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants