Opened 2 years ago

Last modified 5 months ago

#15819 new enhancement

Create user_can_for_blog function

Reported by: mweichert Owned by:
Priority: normal Milestone: Future Release
Component: Role/Capability Version: 3.1
Severity: normal Keywords: has-patch needs-testing
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 2 years ago.
Add user_can_for_blog function to capabilities.php
capabilities.php.diff (1.0 KB) - added by layotte 5 months ago.
Updated patch for user_can_for_blog to deal with non-multisite properly, etc.

Download all attachments as: .zip

Change History (6)

Add user_can_for_blog function to capabilities.php

  • Milestone changed from Awaiting Review to Future Release

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

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

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().

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.