WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#15819 new enhancement

Create user_can_for_blog function

Reported by: mweichert Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Role/Capability Keywords: has-patch needs-testing
Focuses: Cc:

Description

To compliment #14602, a user_can_for_blog function is needed.

Currently we have no function to pass a user ID, blog, and a capability/role which will return whether the user can perform that role or has that capability for a particular blog.

See attached patch please.

Thanks,
Mike

Attachments (2)

user_can_for_blog.patch (1.2 KB) - added by mweichert 4 years ago.
Add user_can_for_blog function to capabilities.php
capabilities.php.diff (1.0 KB) - added by layotte 2 years ago.
Updated patch for user_can_for_blog to deal with non-multisite properly, etc.

Download all attachments as: .zip

Change History (6)

@mweichert4 years ago

Add user_can_for_blog function to capabilities.php

comment:1 @markjaquith4 years ago

  • Milestone changed from Awaiting Review to Future Release

@layotte2 years ago

Updated patch for user_can_for_blog to deal with non-multisite properly, etc.

comment:2 @layotte2 years ago

Added a newer version, would be great to see this in a release soon :). The version I added deals with non-multisite installations appropriately.

comment:3 @nacin2 years ago

Not sure if this is necessary given how rarely the user_can() function is used. You should just do switch_to_blog(), user_can(), restore_current_blog().

comment:4 @layotte2 years ago

Yeah, that's what I ended up doing for the time being... figured it'd be good, since it's there for current_user_can_for_blog().

Note: See TracTickets for help on using tickets.