Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin: Don't require publish_post cap to get activitypub cap #1210

Merged
merged 4 commits into from
Feb 3, 2025

Conversation

obenland
Copy link
Member

Gives context to why a user couldn't be given ActivityPub access, rather than failing silently.

Proposed changes:

  • Adds a callback to display an error message
image

Testing instructions:

  • Create a new user with a Subscriber role.
  • In the Users list, select the Subscriber and enable Activitypub for them.
  • See the error message.

@obenland obenland requested a review from a team January 23, 2025 19:58
@obenland obenland self-assigned this Jan 23, 2025
@pfefferle
Copy link
Member

This was on purpose. The publish_post cap is not required, because big news companies might want to post in the name of guest authors for example.

@obenland
Copy link
Member Author

Hm, not quite sure I understand. It currently only adds the activtipub cap if the user already has publish_posts.

The PR doesn't change that, fwiw, it just surfaces a message now when that condition gets hit, to no longer fail silently.

@pfefferle
Copy link
Member

No, this is only the default we set when you install the plugin, but you can add the cap to every user regardless of the publish_posts cap.

@obenland obenland changed the title Admin: Show error message when user can't publish posts Admin: Don't require publish_post cap to get activitypub cap Jan 27, 2025
$user = \get_user_by( 'id', $user_id );
$user->add_cap( 'activitypub' );
}
\get_user_by( 'id', $user_id )->add_cap( 'activitypub' );
Copy link
Member

Choose a reason for hiding this comment

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

By default we only want to add the "activitypub" capability to users that can edit posts. The admin can change this afterwards.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I misunderstood your comment then

// Add ActivityPub capability to all users that can publish posts.
foreach ( $users as $user ) {
// Add ActivityPub capability to all users.
foreach ( \get_users() as $user ) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here: Only users with the publish_post capability should be migrated, the rest has to be done by hand.

@obenland obenland force-pushed the add/user-error-notice branch from d31bb8b to 59d69f2 Compare February 3, 2025 08:20
@obenland obenland merged commit d71f5a5 into trunk Feb 3, 2025
11 checks passed
@obenland obenland deleted the add/user-error-notice branch February 3, 2025 08:47
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.

2 participants