Unsupported_Products::disallow_publication( array $caps, string $cap, int $user_id, array $args )
Summary
Users should not be permitted to publish unsupported posts.
Description
Unfortunately, WP does not provide granular caps for publishing posts, so we are left with a blanket cap for publishing all posts. We just apply this filter on the product single admin, but can do nothing about quick edit in the products list table.
Parameters
- $caps
-
(array) (Required) Returns the user's actual capabilities.
- $cap
-
(string) (Required) Capability name.
- $user_id
-
(int) (Required) The user ID.
- $args
-
(array) (Required) Adds the context to the cap. Typically the object ID.
Return
(array)
Source
File: src/BigCommerce/Post_Types/Product/Unsupported_Products.php
public function disallow_publication( $caps, $cap, $user_id, $args ) { if ( $cap == 'publish_posts' && is_admin() && function_exists( 'get_current_screen' ) ) { $screen = get_current_screen(); if ( $screen && $screen->base == 'post' && isset( $_GET[ 'post' ] ) && $this->is_unsupported_product( (int) $_GET[ 'post' ] ) ) { $caps[] = 'do_not_allow'; } } return $caps; }