I want to create a event website where a taxonomy of the event will be public and private. If the event is set as public then it will be available to all users. But if it is set as private then only those users who are invited ( how to perform this invitation using toolset?)by the event author , they will be able to access it. Please help me to achieve this goal.
Hi there,
You can use the Toolset Access plugin to force a taxonomy or a post type to have/not have read permission for all users.
Then using the Toolset Access you can create a new Custom User Role that if assigned to that role, then the user with that role can read the event.
For more information:
https://toolset.com/course-chapter/controlling-access-to-content-in-directory-sites/
There is no invite feature in Toolset an most probably you will need to do custom PHP coding for that.
Thanks for the reply. Is it possible to hide post items of certain taxonomy from the original post type archive and taxonomy archive including WordPress native searching result.
Hi there,
Toolset does not have such a feature and you need ot use a custom code to do that. Something like:
function exclude_custom_taxonomy_from_search( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( $query->is_search ) {
$tax_query = array(
array(
'taxonomy' => 'your_custom_taxonomy_slug',
'field' => 'slug',
'terms' => get_query_var( 's' ),
'operator' => 'NOT IN',
)
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'pre_get_posts', 'exclude_custom_taxonomy_from_search' );
Replace 'your_custom_taxonomy_slug' with the slug of the taxonomy that you want to exclude from the search results.
Once you add this code, the post items of the excluded taxonomy will not appear in the WordPress native searching result.
The code suggested is not tested and is not guaranteed to work. To know more aboutpre_get_posts please check this documentation:
https://developer.wordpress.org/reference/hooks/pre_get_posts/
If you want to get help from a developer you can consider hiring a Toolset contractor here:
https://toolset.com/contractors/
Thanks.