Authorization hook implemented.

This commit is contained in:
Geoff Taylor
2019-07-06 10:22:07 -04:00
parent bb4f5cbd50
commit fd80867ac0
4 changed files with 22 additions and 9 deletions
@@ -14,6 +14,25 @@ use GraphQL\Error\UserError;
* Class - Order_Mutation
*/
class Order_Mutation {
/**
* Filterable authentication function.
*
* @param string $mutation Mutation being executed.
*
* @return boolean
*/
public static function authorized( $mutation = 'create', $input, $context, $info ) {
$post_type_object = get_post_type_object( 'shop_order' );
return apply_filters(
"authorized_to_{$mutation}_orders",
! current_user_can( $post_type_object->cap->create_posts ),
$input,
$context,
$info
);
}
/**
* Create an order.
*