bbp_suppress_private_author_link( $author_link,  $args )

Replace forum author details for users that cannot view them.

Description

Parameters

$retval

(Required)

$forum_id

(Required)

Return

(string)

Source

File: bp-forums/forums/template.php

1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
function bbp_suppress_private_author_link( $author_link, $args ) {
 
    // Assume the author link is the return value
    $retval = $author_link;
 
    // Show the normal author link
    if ( !empty( $args['post_id'] ) && !current_user_can( 'read_private_forums' ) ) {
 
        // What post type are we looking at?
        $post_type = get_post_field( 'post_type', $args['post_id'] );
 
        switch ( $post_type ) {
 
            // Topic
            case bbp_get_topic_post_type() :
                if ( bbp_is_forum_private( bbp_get_topic_forum_id( $args['post_id'] ) ) )
                    $retval = '';
 
                break;
 
            // Reply
            case bbp_get_reply_post_type() :
                if ( bbp_is_forum_private( bbp_get_reply_forum_id( $args['post_id'] ) ) )
                    $retval = '';
 
                break;
 
            // Post
            default :
                if ( bbp_is_forum_private( $args['post_id'] ) )
                    $retval = '';
 
                break;
        }
    }
 
    return apply_filters( 'bbp_suppress_private_author_link', $retval );
}

Changelog

Changelog
Version Description
bbPress (r3162) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.