This ticket is the follow of the old ticket
https://toolset.com/forums/topic/access-control-where-user-is-replicated-as-post-with-relationship-to-post-types/
Adding contributor to the customers solves all the problem, but an unusual behavior is happening on the site.
I have a custom-post type from a third party plugin. I created a shortcode which would return all the posts according to the the query.
function archive_classes_public($atts){
$atts = shortcode_atts(
array(
'limit' => '',
),
$atts
);
$limited = $atts['limit'];
if($limited != " " ) {
$limit = $limited;
}
else {
$limit = -1;
}
date_default_timezone_set('Asia/Calcutta');
$today = date("Y-m-d H:i");
$args = array(
'post_type' => 'zoom-meetings',
'post_status' => 'publish',
'posts_per_page' => $limit,
'meta_key' => '_meeting_start_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_meeting_start_date',
'value' => $today,
'compare' => '>',
'type' => 'datetime'
),
),
);
$loop = new WP_Query( $args );
$total_cards = "";
$content .= "<div class='class-wrapper'>";
while ( $loop->have_posts() ) : $loop->the_post();
$product_id = get_post_meta( get_the_ID(), "_vczapi_zoom_product_id" ,true );
$content_of_product_card = render_class_from_product_id_public($product_id);
if(gettype($content_of_product_card) == "string" ) {
$total_cards .= $content_of_product_card;
}
endwhile;
$content .= $total_cards;
$content .= "</div>";
if($total_cards == ""){
$content .= "No Upcoming Classes Added. ";
}
wp_reset_postdata();
return $content;
}
add_shortcode('archive_classes_public', 'archive_classes_public');
After I have started using Toolset access in the post type the code runs only at one place : hidden link and wont work on other hidden link locations. Only when the customer logs in with contributor role capabilities the query returns posts.
I have marked guest user to be able to read the post.
Screenshot attached.
Hello,
The problem you mentioned above is abnormal, if you have enabled permission for guest users, then it should be able to output posts for guests, I suggest you check the compatibility issue first:
Deactivate all other plugins, and switch to wordpress default theme 2020, and test again
And Toolset Access plugin is using WordPress hook "posts_where" to apply the filters, you can also disable filters from Access plugin by adding a line in your custom PHP codes, for example, add change this line from:
To:
'order' => 'ASC',
'suppress_filters' => true,
More help:
https://developer.wordpress.org/reference/classes/wp_query/
@type bool $suppress_filters Whether to suppress filters. Default false.