HI guys I’m trying to write a simple shortcode that hides some content from a buddypress member type.
BUT the info appears in a user post, so we want to hide the item IF the post author is that member type.
The plugins available hide the content if the logged in user is the member type, I need to hide the content if the post author has a particular post type.
And, every wanting to learn and get better at PHP.
This is a hard one for me, hope I did it not to far off.
/**
- Hide content from Casting Buyers
*/
function hide_from_casting_function( $atts, $content = null ) {
// fetch post author id
$user_id = get_the_author_meta(‘ID’);
// Get the member type of user the author.
$member_type = bp_get_member_type( $user_id );
// if casting_buyer hide from front end.
if ( ‘casting_buyer_type’ != $member_type )
{return ‘’ . $content . ‘’;}
}
add_shortcode(‘hide_from_casting’, ‘hide_from_casting_function’);