Skip to:

how to get author of post’s member type and hide

  • yelgnissm


    Hi I’m trying to get the member type of the post author using php and then create a shortcode to tell the post to hide particular information if the post author, in the site overall, is a certain member type. Not the use, the post author.

    So the user is logged in
    they get to a directory listing that has an author who is a member type.
    I want to hide a block of copy jsut using a shortcode.

    I tried this, but it’s hiding the information for all post types.

     * Hide content from Casting Buyers
    function hide_if_casting_buyer_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 ( $member_type == 'casting_buyer_type' ) 
    	{return '<span style="display:none">' . $content . '</span>';}
    add_shortcode('hide_if_casting_buyer', 'hide_if_casting_buyer_function'); */

    I’m already hiding the box from everybody who is not logged in. using css
    in this case, I want to hide the info for any author who is casting_buyer_type.

    I tried the plugins from buddydev, but their shortcodes hide if the user is a particular member type. I want to hide if the post author of the post is a particular member type.

  • You must be logged in to reply to this topic.
Skip to toolbar