Skip Navigation

[Resolved] How to create a event post which will be a private event?

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Christopher Amirian 3 years ago.

Assisted by: Christopher Amirian.

Author
Posts
#2566133

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.

#2566307

Christopher Amirian
Supporter

Languages: English (English )

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.

#2566317

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.

#2566813

Christopher Amirian
Supporter

Languages: English (English )

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.