Skip Navigation

Access API Filters

toolset_access_api_get_post_permissions

Description

Filter to check permission for specific post.

Arguments
  • bool $has_permission

  • string|int|WP_Post|null $post_source Valid post ID or a post object. Defaults to the current post.

  • string $permission_type Type of the permission to check. Possible values: read, edit. Optional. Defaults to read.

  • int|WP_User $user User to check permission for. Optional. Defaults to current user.

  • string $language_code The language code of the post, i.e. en. Optional. Defaults to default language.

Output

bool

More Usage examples

Example

$has_permission = current_user_can('edit_posts');
$has_permissions = apply_filters('toolset_access_api_get_post_permissions', $has_permission, 1, 'edit', $current_user, 'en');

toolset_access_api_get_post_type_permissions

Description

Filter to check permission for specific post type.

Arguments
  • bool $has_permission

  • string $post_type_slug The slug of the post type.

  • string $permission_type Type of the permission to check. Possible values: publish, edit_own, edit_any, delete_own, delete_any, read. Optional. Defaults to read.

  • int|WP_User $user User to check permission for. Optional. Defaults to current user.

  • string $language_code The language code of the post, i.e. en. Optional. Defaults to default language.

Output

bool

More Usage examples

Example

$has_permission = current_user_can('edit_posts');
$has_permissions = apply_filters('toolset_access_api_get_post_type_permissions', $has_permission, 'page', 'edit_own', $current_user, 'en');

toolset_access_api_get_taxonomy_permissions

Description

Filter to check permission for specific taxonomy.

Arguments
  • bool $has_permission

  • string $taxonomy_slug The slug of the taxonomy.

  • string $permission_type Type of the permission to check. Possible values: assign_terms, delete_terms, edit_terms, manage_terms. Optional. Defaults to manage_terms.

  • int|WP_User $user User to check permission for. Optional. Defaults to current user.

Output

bool

More Usage examples

Example

$has_permission = current_user_can('manage_categories');
$has_permissions = apply_filters('toolset_access_api_get_taxonomy_permissions', $has_permission, 'category', 'manage_terms', $current_user);

toolset_editor_access_button_disable_by_role

Description

Use this filter to define for which specific user roles should the Access button be hidden.

Arguments
  • array $roles This filter takes only one argument and it must return an array. The returned array contains the roles for which Access editor button will be disabled. For example, returning array( 'author', 'subscriber') means that the Access editor button will not be available for users with an author or subscriber role.

Output

array

More Usage examples

Example
add_filter('toolset_editor_access_button_disable_by_role','wpcf_hide_access_button');
function wpcf_hide_access_button( $roles=array() ){
return array('author', 'subscriber');
}