-
Notifications
You must be signed in to change notification settings - Fork 7
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
Adding attribute_post_type does not allow you to attribute_post_type #111
Comments
I've attempted to work around this with a filter but it should be unnecessary, and it's sub-optimal: add_filter( 'user_has_cap', __NAMESPACE__ . '\\author_filter_user_has_cap', 11, 4 );
/**
* Filters attribute_post_type
*
* @param bool[] $user_caps Array of key/value pairs where keys represent a capability name and boolean values
* represent whether the user has that capability.
* @param string[] $required_caps Array of required primitive capabilities for the requested capability.
* @param mixed[] $args {
* Arguments that accompany the requested capability check.
*
* @type string $0 Requested capability.
* @type int $1 Concerned user ID.
* @type mixed ...$2 Optional second and further parameters.
* }
* @param WP_User $user Concerned user object.
* @return bool[] Array of concerned user's capabilities.
*/
function author_filter_user_has_cap( array $user_caps, array $required_caps, array $args, WP_User $user ) : array {
$cap = $args[0];
if ( ( $cap === 'attribute_post_type' ) && ( in_array( 'author', $user->roles, true ) ) ){
$user_caps['attribute_post_type'] = true;
}
return $user_caps;
} |
Noting the above workaround does not work 😞 |
There should be test coverage for this in |
Not sure, but a client is struggling pretty badly to get authors to be able to assign guest authors on their posts, and they've confirmed via WP CLI that It should be noted they also do not want authors to be able to create new guest authors |
in theory #113 would fix this by handling this more logically, and adds commenting so it's clearer. It also fixes that it falls back to edit others posts but does not pass the post ID when it performs that check |
I would expect the |
As noted in #113 (comment) I tracked this down further, and this issue is specific to users that do not have the The concern is that the client I'm working with expects that an author can add guest authors to their posts, but this isn't possible, even when they have the capability. This is due to how Authorship adds the capability to the REST response which depends on detecting then removing the ability to assign an author that requires One thing that could be done and is implemented via the workaround is to change the check to instead call |
Because of a user cap meta filter, this capability is never actually checked for and is overriden by:
authorship/inc/namespace.php
Line 267 in ad162b1
This means it's not possible for an author to write a post with guest authors, even if they have the
attribute_post_type
capabilityThe text was updated successfully, but these errors were encountered: