wc_rest_check_product_term_permissions( string $taxonomy, string $context = 'read', int $object_id )

Check permissions of product terms on REST API.


Description Description


Parameters Parameters

$taxonomy

(Required) Taxonomy.

$context

(Optional) Request context.

Default value: 'read'

$object_id

(Required) Post ID.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/wc-rest-functions.php

function wc_rest_check_product_term_permissions( $taxonomy, $context = 'read', $object_id = 0 ) {
	$contexts = array(
		'read'   => 'manage_terms',
		'create' => 'edit_terms',
		'edit'   => 'edit_terms',
		'delete' => 'delete_terms',
		'batch'  => 'edit_terms',
	);

	$cap             = $contexts[ $context ];
	$taxonomy_object = get_taxonomy( $taxonomy );
	$permission      = current_user_can( $taxonomy_object->cap->$cap, $object_id );

	return apply_filters( 'woocommerce_rest_check_permissions', $permission, $context, $object_id, $taxonomy );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.