Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateDivergenceDetector::rest_meta_auth_read_only
REST auth gate for _wc_email_template_* meta.
- Read: allowed for users who can edit
woo_emailposts (matches the email-list capability). - Write: never allowed via REST. Meta is owned by server-side detection, apply, and reset flows.
Signature follows the auth_{$object_type}_meta_{$meta_key} filter contract.
Method of the class: WCEmailTemplateDivergenceDetector{}
No Hooks.
Returns
true|false.
Usage
$result = WCEmailTemplateDivergenceDetector::rest_meta_auth_read_only( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ): bool;
- $allowed(true|false) (required)
- Whether the request is allowed (current state).
- $meta_key(string) (required)
- The meta key in question.
- $object_id(int) (required)
- The post ID.
- $user_id(int) (required)
- The current user ID.
- $cap(string) (required)
- The capability being requested.
- $caps(array) (required)
- The full set of caps the user must have.
Changelog
| Since 10.9.0 | Introduced. |
WCEmailTemplateDivergenceDetector::rest_meta_auth_read_only() WCEmailTemplateDivergenceDetector::rest meta auth read only code WC 10.9.4
public static function rest_meta_auth_read_only( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ): bool {
unset( $allowed, $meta_key, $caps );
// Block all writes regardless of caller.
if ( in_array( $cap, array( 'edit_post_meta', 'add_post_meta', 'delete_post_meta' ), true ) ) {
return false;
}
// For reads, defer to whether the user can edit the post.
return user_can( $user_id, 'edit_post', $object_id );
}