We created a post group for members-only content and I created a content template to use for non-members so that they see a message to join the membership to see it. It shows up correctly in the post content area, but the post's comments are still visible down below. I looked in the settings for the content template I created and there is no setting for not showing comments. I looked in every area on the right sidebar to find controls but there are none.
We're using this on existing posts using the regular WordPress posts.
Example page: hidden link
Hi,
Thank you for contacting us and I'd be happy to assist.
To troubleshoot this, I'll need to see how these connected elements are set up in the admin area.
Can you please share temporary admin login details, in reply to this message?
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
regards,
Waqar
Thank you for sharing this, but I'm getting the incorrect username/password message.
Can you please check the username and password again?
I'm setting your next as private.
Thank you for sharing these details.
Looking into your website's settings, I can confirm that the Toolset Access post group restrictions are only applied to the content/body section and they don't automatically extend to the comment section.
To apply them to the comments sections too, you can use the filter "toolset_access_api_get_post_permissions":
https://toolset.com/documentation/programmer-reference/access-api-filters/#toolset_access_api_get_post_permissions
For example, the following code snippet for the Genesis framework, will check if the current user has permission to access the current post's content or not and if not, will remove the comment section:
function custom_remove_comments_access() {
$userid = get_current_user_id();
global $post;
if (defined('ICL_LANGUAGE_CODE')) {
$allowed = apply_filters( 'toolset_access_api_get_post_permissions', true, $post, 'read', $userid, ICL_LANGUAGE_CODE );
}
else {
$allowed = apply_filters( 'toolset_access_api_get_post_permissions', true, $post, 'read', $userid );
}
$return = ( $allowed ) ? 1:0;
if($return == 0) {
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
}
}
add_action( 'genesis_after_entry', 'custom_remove_comments_access', 0 );
Note: You can include this code snippet at the bottom of your child theme's "functions.php" file.
I hope this helps and please let me know if you need any further assistance around this.
Thank you, Waqar! That is exactly what I needed. Thank you for providing a solution, considering the Genesis framework needs. It works great.