Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add ‘@’ when replying

  • @vincenzon617

    Participant

    Is there a way I can add an “@username…” to the start of the message when someone is replying?
    I have threaded replies enabled and to make it clear to who they are replying to I would like to automatically @ the author.

    I know that the user can do this manually themselves but in the case they do not, this would be helpful.

    Thanks

Viewing 1 replies (of 1 total)
  • @jappan

    Participant
    add_filter( 'bbp_get_form_reply_content', function( string $reply_content ) {
        if ( isset( $_GET['bbp_reply_to'] ) && (int) $_GET['bbp_reply_to'] ) {
            $display_name = get_the_author_meta( 'display_name', get_post_field( 'post_author', (int) $_GET['bbp_reply_to'] ) );
            return '@' . $display_name . PHP_EOL . $reply_content;
        }
    	return $reply_content;
    });

    You should add this code in “functions.php”.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar