Skip Navigation

[Resolved] After adding a template to tease member-only content, post comments still appear

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by DavidB4145 1 year, 7 months ago.

Assisted by: Waqar.

Author
Posts
#2462177
Screen Shot 2022-09-21 at 9.32.41 AM.png
Screen Shot 2022-09-21 at 9.30.14 AM.png
Screen Shot 2022-09-21 at 9.30.27 AM.png
Screen Shot 2022-09-21 at 9.25.00 AM.png

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

#2462695

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#2463429

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

#2465057

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

#2465103

Thank you, Waqar! That is exactly what I needed. Thank you for providing a solution, considering the Genesis framework needs. It works great.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.