Skip to:
Content
Pages
Categories
Search
Top
Bottom

add custom profile field or group as signature?


  • carterlongbeach
    Participant

    @carterlongbeach

    Hi. I’d like to automatically include a hyperlink to users’ groups (Buddypress) or a custom profile field (BBpress) in all of their topic and response posts in forums. It would be something like a signature, but would be automatic, not a choice.

    Any suggestions? I’m not a coder.

    I’ve searched support and plugins to no avail. Thanks.

    Running WP Version 3.8.2 , BP Version 1.9.2, BBpress Version 2.5.3

Viewing 6 replies - 1 through 6 (of 6 total)
  • There are a few bbPress signature plugins, maybe one of these will do what you are looking for
    https://wordpress.org/plugins/search.php?q=signature+bbpress


    carterlongbeach
    Participant

    @carterlongbeach

    I don’t know if it is the most efficient solution, but I found something that works.

    I created a new profile field with Register Plus Redux (new field called rpr_testfield).

    I then modified bbp profile information with the following code, starting on line 26…

    $usermeta = get_userdata( $user_id, 'rpr_testfield' );
    echo $usermeta->rpr_testfield;
    if ($usermeta->rpr_testfield == 'school name from profile')  
    echo "<a href="http://www.hyperlink?pID=19" target="_blank">School web page</a>";

    Now all posts include the name of the user’s school with a hyperlink to the school webpage.

    I am not sure how Register Plus Redux registers the new profile fields though an alternate way would be to use user_contactmethods

    https://codex.wordpress.org/Plugin_API/Filter_Reference/user_contactmethods

    So here is an alternate method using that method as a single standalone plugin:

    I’m not saying there is anything wrong with the method you used, just an alternate method.

    You could add as many or few extra fields as you want 😉

    Source: https://gist.github.com/ntwb/11241301

    
    <?php
    /*
    Plugin Name: bbPress - CLB Add user school to reply author details
    Plugin URI: https://gist.github.com/ntwb/11241301
    Description: bbPress - CLB Add user school to reply author details
    Version: 0.1
    Author: Stephen Edgar - Netweb
    Author URI: http://netweb.com.au
    */
    
    function clb_user_contact_methods( $user_contact ){
    
    	/* Add user contact methods */
    	$user_contact['school'] = __('School Name');
    
    	return $user_contact;
    }
    add_filter('user_contactmethods', 'clb_user_contact_methods');
    
    function clb_school_replies_author() {
    
    	echo get_user_meta(bbp_get_reply_author_id(), 'school', true);
    
    }
    add_action( 'bbp_theme_after_reply_author_details', 'clb_school_replies_author' );
    
    

    As it displays in each reply under the author details

    As it displays on a users profile page


    carterlongbeach
    Participant

    @carterlongbeach

    Thanks Stephen. I’ll take a look at that as well.


    carterlongbeach
    Participant

    @carterlongbeach

    Thanks for the code! I just modified it by commenting out the add user contacts section and using the Register Plus Redux field (which requires users to pick a school upon registration).

    I then added code to echo a hyperlink. For each new school I will add new hyperlink code. So far it seems to be working!

    function clb_school_replies_author() {
     
    echo get_user_meta(bbp_get_reply_author_id(), 'rpr_testfield', true); 
    
    if (get_user_meta(bbp_get_reply_author_id(), 'rpr_testfield', true) == 'school1')  
    echo nl2br ("\n<a href=http://www.school1.edu target=_blank>School 1 Web Page</a>");
    
    if (get_user_meta(bbp_get_reply_author_id(), 'rpr_testfield', true) == 'school2')  
    echo nl2br ("\n<a href=http://www.school2.edu target=_blank>School 2 Web Page</a>");
    

    Cool, glad you have something your happy with 🙂

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