gpsa_has_access
Description
Filter whether the current viewer has access to the given content.
Usage
Applied globally
add_filter( 'gpsa_has_access', 'my_custom_function' );
Parameters
$has_access
bool
Whether the current viewer has access.
$args
array
The context and data associated with the content. This is a union type, so one should check the context before trying to access associated properties. Here is a list of the context types and their associated properties.
Document: Determines if the user has access to the specified post object.
context
'document'
Defaults to document
.
post_id
int|null
The ID of the post.
Block: Determines if the user has access to the specified Block Editor block.
context
'block'
Defaults to block
.
post_id
int|null
The ID of the post.
post
WP_Post|null
The post object.
block
WP_Block|null
The block object.
Shortcode: Used to determine if the user has access to the content within a specified
context
'shortcode'
Defaults to shortcode
.
post_id
int|null
The ID of the post.
shortcode
array
The shortcode attributes.
Examples
Grant access by user role
This example automatically grants access for all users with the administrator
role.
Since
1.0
Hook added.