mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
Authorization hook implemented.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user