Skip to:
Content
Pages
Categories
Search
Top
Bottom

Very simple forum Signature with Xprofile


  • patrix87
    Participant

    @patrix87

    I modified a little script I found inside a plugin named “bbp signature” https://wordpress.org/plugins/bbp-signature/
    That plugin actually does not work with Buddypress, it is a bbpress plugin
    [modified by moderator]

    But the code wasn’t too terrible. even though I only kept a few line of it.

    So here’s the solution;

    make sure you have buddypress with xprofile enabled *(extended profiles)

    1. Create a new text box field in Xprofile and name it “Signature”. *(caps is important, no quotation mark.)

    Then add that code to the function.php of your child theme.

    
    //Add Signature
    
    function bbp_reply_content_append_user_signature( $content = '', $reply_id = 0, $args = array() ) {
    	// Default arguments
    	$defaults = array(
    		'separator' => '<hr />',
    		'before'    => '<div class="bbp-signature">',
    		'after'     => '</div>'
    	);
    	$r = wp_parse_args( $args, $defaults );
    	extract( $r );
    
    	// Verify topic id, get author id, and potential signature
    	$reply_id  = bbp_get_reply_id       ( $reply_id );
    	$user_id   = bbp_get_reply_author_id( $reply_id );
    	$signature = xprofile_get_field_data( 'Signature', $user_id );
    
    	// If signature exists, adjust the content accordingly
    	if ( !empty( $signature ))
    		$content = $content . $separator . $before . $signature . $after;
    
    	return apply_filters( 'bbp_reply_content_append_signature', $content, $reply_id, $separator );
    }
    
    add_filter( 'bbp_get_reply_content', 'bbp_reply_content_append_user_signature', 1, 2 );
    
    

    That’s it !

    PS. If you want to enable HTML in xprofile there is a way but it’s risky.
    you can read about it here : https://buddypress.org/support/topic/html-in-profile-field-again/

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

  • patrix87
    Participant

    @patrix87

    Safer way to allow img tag :

    simply add that to your function.php

    // Add img tag to filter
    
    function gawd_allowed_tags() {
    	global $allowedtags;
    	$allowedtags['img'] = array( 'src' => array () );
    }
    
    add_action('init', 'gawd_allowed_tags', 10);
    

    Robkk
    Moderator

    @robkk

    I think that plugin works best without BuddyPress installed.

    Thanks for sharing though.


    patrix87
    Participant

    @patrix87

    I think it was made to work with buddypress groups whitout xprofiles yes. A simple update could fix that.


    fabwintle
    Participant

    @fabwintle

    @patri87

    THANK YOU! I have been struggling with this plugin and just did a bit more googling and bam, here ws your post. I really appreciate you posting this fix.


    Raj
    Participant

    @rajkumarsam786

    Thank you for solution


    Robin W
    Moderator

    @robin-w

    The bbp-signature plugin is designed to work with bbpress not with buddypress, so it works fine – I’ve amended your original post to reflect that for future users in the first post to save them needing to read the whole thread.

    But the code wasn't too terrible

    General open software etiquette is not to insult other software authors, we are all at different levels and any software that works is useful 🙂

    The original author of this software is unable to continue supporting it, so I have access to it so that it can continue.

    I think it was made to work with buddypress groups whitout xprofiles yes. A simple update could fix that.

    If you’d care to suggest code that would make it work for users with and without buddypress, please contact me via my website, as I’d love to include it in the plugin

    http://www.rewweb.co.uk


    patrix87
    Participant

    @patrix87

    Sorry about that, I did not intend to insult anyone, French is my first language and maybe that sound worst that I intended it to be.

    For the update you could add a line to check for buddypress xprofiles and check this field instead of the bbpress one :

    xprofile_get_field_data( 'Signature', $user_id );

    sorry again about that.


    Robin W
    Moderator

    @robin-w

    hey no problem !


    fabwintle
    Participant

    @fabwintle

    Thanks very much for this @patrix87.

    I would like to add <br/> or at least customise that signature a little bit. I don’t need an html editor in there, but just be able to add elements on different lines. What do you recommend I use?


    ghoush
    Participant

    @ghoush

    Just a note to everyone who might find this. It’s been more than 4 years, and this code still works great.

    For anyone looking to add signatures on BuddyBoss Platform instead of bbPress/BuddyPress, this works too.


    Robin W
    Moderator

    @robin-w

    great! thanks for posting

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