Skip to:
Content
Pages
Categories
Search
Top
Bottom

Give Admin/Keymaster ONLY a forum signature?


  • reedy
    Participant

    @reedy

    Is there a way to append a signature to posts made by a Keymaster — perhaps by adding something in functions.php?

    I don’t want to offer signatures for all users of the forum so installing a plugin for this (IMHO) is a bit of overkill.

    Thanks in advance for any info/pointers.

Viewing 12 replies - 1 through 12 (of 12 total)

  • Robin W
    Moderator

    @robin-w

    a common signature, or a different one per keymaster ?


    reedy
    Participant

    @reedy

    I only have one keymaster, so for my use I’d just want to be able to set a signature for the sole keymaster.


    brinkley
    Participant

    @brinkley

    A great question. I would be interested in multiples though.


    Robin W
    Moderator

    @robin-w

    untested but try

    add_filter( 'bbp_get_reply_content', 'rew_reply_signature', 1, 2 );
    add_filter( 'bbp_get_topic_content', 'rew_topic_signature', 1, 2 );
    
    function rew_topic_signature ($content = '', $topic_id = 0) {
    	$topic_id  = bbp_get_topic_id       ( $topic_id );
    	$user_id   = bbp_get_topic_author_id( $topic_id );
    	$separator = '<hr />' ;
    	$before = '<div class="bbp-topic-signature">' ;
    	$after = '</div>' ;
    	if ($user_id == 3) $signature =  'signature for user 3' ;
    	if ($user_id == 57) $signature 'signature for user 57' ;
    	if ( !empty( $signature ) )
    		$content = $content . $separator . $before . $signature . $after;
    	return apply_filters( 'rew_topic_signature ', $content, $topic_id) ;
    }
    
    function rew_reply_signature ($content = '', $reply_id = 0) {
    	$reply_id  = bbp_get_reply_id       ( $reply_id );
    	$user_id   = bbp_get_reply_author_id( $reply_id );
    	$separator = '<hr />' ;
    	$before = '<div class="bbp-reply-signature">' ;
    	$after = '</div>' ;
    	if ($user_id == 3) $signature =  'signature for user 3' ;
    	if ($user_id == 57) $signature 'signature for user 57' ;
    	if ( !empty( $signature ) )
    		$content = $content . $separator . $before . $signature . $after;
    	return apply_filters( 'rew_reply_signature ', $content, $reply_id) ;
    }

    Put this in your child theme’s function file – or use

    Code Snippets


    Robin W
    Moderator

    @robin-w

    above amended – spotted an error


    reedy
    Participant

    @reedy

    This is fantastic — I will definitely test this out.

    Am I right in thinking that the two times this line appears:

    if ($user_id == 57) $signature 'signature for user 57' ;

    Should actually read as:

    if ($user_id == 57) $signature = 'signature for user 57' ;


    Robin W
    Moderator

    @robin-w

    yes !


    reedy
    Participant

    @reedy

    Unfortunately, this code didn’t work — it removed the content of all forum posts!

    @robin-w I suppose your first line
    add_filter( ‘bbp_get_reply_content’, ‘rew_signature’, 1, 2 );
    Should have been
    add_filter( ‘bbp_get_reply_content’, ‘rew_reply_signature’, 1, 2 );
    right?

    And same remark for the topic line below


    Robin W
    Moderator

    @robin-w

    @casiepa thanks for that spot – yes !!


    reedy
    Participant

    @reedy

    That got it! Thank you both so much!


    Robin W
    Moderator

    @robin-w

    great – glad you are fixed

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