Make WordPress Core

Opened 5 years ago

Last modified 3 days ago

#45197 reviewing enhancement

Introduce `user_can_for_blog()`

Reported by: johnbillion's profile johnbillion Owned by: johnbillion's profile johnbillion
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Role/Capability Keywords: has-patch has-unit-tests
Focuses: multisite Cc:

Description

The available user capability checking functions include:

  • current_user_can()
  • user_can()
  • current_user_can_for_blog()

What's missing is user_can_for_blog() so that both a user ID and a site ID can be passed in order to check a given user's capabilities on a given site.

Attachments (1)

45197.diff (1.1 KB) - added by tmanoilov 5 years ago.

Download all attachments as: .zip

Change History (6)

#1 @johnjamesjacoby
5 years ago

+1 to this.

I have coded some version of this logic at least a few times (into private methods in plugins.)

I can adapt something into a patch, but it’s pretty straight forward if anyone wants to try.

Last edited 5 years ago by johnjamesjacoby (previous) (diff)

@tmanoilov
5 years ago

#2 @tmanoilov
5 years ago

  • Keywords has-patch added; needs-patch removed

Hey guys, I'm at WordCamp Sofia 2018 Contributors day and this is the first patch I'm submitting. I'm not able to fully test it so I'm looking forward to a review. Thanks in advance.

#3 @johnbillion
7 weeks ago

  • Milestone changed from Future Release to 6.6
  • Owner set to johnbillion
  • Status changed from new to reviewing

This ticket was mentioned in PR #6418 on WordPress/wordpress-develop by @rajinsharwar.


3 days ago
#4

  • Keywords has-unit-tests added; needs-unit-tests removed

Adding a new function named user_can_for_blog(), and unit tests for it.

Trac ticket: https://core.trac.wordpress.org/ticket/45197

#5 @rajinsharwar
3 days ago

Added the new function, along with its unit tests.

Note: See TracTickets for help on using tickets.