Last active
May 27, 2019 05:44
-
-
Save kimcoleman/fa679a2fb991df42d320db15cb0a68fd to your computer and use it in GitHub Desktop.
Do not return the post thumbnail (featured image) on restricted content when viewed by a non-member.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Do not return the post thumbnail (featured image) on restricted content when viewed by a non-member. | |
* | |
*/ | |
function hide_post_thumbnail_on_restricted_content( $html, $post_id, $post_image_id ) { | |
if ( function_exists( 'pmpro_has_membership_access' ) ) { | |
// Check if the user has access to the post. | |
$hasaccess = pmpro_has_membership_access( $post_id ); | |
if ( empty( $hasaccess ) ) { | |
$html = ''; | |
} | |
} | |
return $html; | |
} | |
add_filter( 'post_thumbnail_html', 'hide_post_thumbnail_on_restricted_content', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment