Skip to:
Content
Pages
Categories
Search
Top
Bottom

to Mr Robin W… How to show "Website" part at User Profile


  • yoosuke
    Participant

    @yoosuke

    I’m here again!
    It’s great I have a place to come back!

    Now, I’m looking for advice on How to show “Website” part at User Profile page.
    By default, 4 sections are displayed on User Profile page.

    1.user-description, 2.forum-role, 3.topic-count, 4.reply-count

    In edit page, There is a section for entering users “Website”.
    in spite of entering the section, it would not be display at User’s Profile page.
    How can I display it at the User’s Profile page.

    I found that I need to add some PHPcodes into “user-profile.php”.
    But as you know, I have no idea What codes I have to put in.

    would you please advice me…

    WordPress: ver3.9.1
    bbPress: ver2.5.3

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

  • Robin W
    Moderator

    @robin-w

    The following should do it – put this in your functions file

    function bbp_website_information () 
    //This function adds the website to the avatar display of topics/replies
    {
    	echo '<li>' ; 
    	$user_id = bbp_get_reply_author_id( $reply_id );
    	global $wpdb;
    	$url = get_userdata($user_id) ;
    	$url=$url->user_url ;
    	$url='<a href="'.$url.'">'.$url.'</a>';
    	echo $url ;
    	echo '</li>' ;
    }
    		
    add_action ('bbp_theme_after_reply_author_details', 'bbp_website_information') ;

    Robin W
    Moderator

    @robin-w

    sorry that will add it after the avatar on topics and replies, just re-read you want it in profile !

    will take another look tomorrow !


    yoosuke
    Participant

    @yoosuke

    Thanks for your attentive respond.

    OK.then, I’m waiting for your reply…


    Robin W
    Moderator

    @robin-w

    Ok, this is what you wanted

    function user_profile_bbp_website_information()
    //this function adds the website to the profile display menu
    			{
    			
    			$label1 =  $rpi_options['item1_label'] ;
    			echo "<p>" ;
    			printf ( __( 'website : ', 'bbpress' ));
    			$url=bbp_get_displayed_user_field( 'user_url' ) ;
    			$url='<a href="'.$url.'">'.$url.'</a>';
    			echo $url; 
    			echo"</p>" ;
    			}
    			
    add_action ('bbp_template_after_user_profile', 'user_profile_bbp_website_information') ;

    There is actually a patch to add this permanently to bbPress 2.6

    https://bbpress.trac.wordpress.org/ticket/2570

    Do you think this is a good idea?

    Should it be an active hyperlink or plain text? (I just realised my patch is only plain text)

    Anyway, for now here is the patch as a plugin https://gist.github.com/ntwb/a19b187f2170235f16bf
    (The extra HTML markup should match it to the existing profile fields for most themes)

    Note: If this is shipped with bbPress 2.6 you will then see two profile fields 😉

    Oh! Hehehe 😉 Always more than one way to do things in WordPress 🙂


    Robin W
    Moderator

    @robin-w

    Great, and yes I think it should be a link – it bugs me to have to copy/paste into a browser – but maybe as a new window?

    Mine didn’t have “Website: ” now it does 😉 yours should also be ‘Website : ‘ (i.e. Capital W) 😉

    It won’t be a link in a new window (i.e. target="_blank"), a big pet peeve of my mine, see this for more background on when to and not to use it.


    Robin W
    Moderator

    @robin-w

    ‘a big pet peeve of my mine’

    and also of mine for exactly the opposite reason !!

    Where I want the user to go down a route and not have to backtrack through 10 pages they have subsequently looked at, then your logic is fine, they will go that way.

    Where clearly you want them to be able to take a look, but not lose where they are, then a new window is logical.

    Finally I dislike the ‘thought police’ making up a standard and then trying to tell us what we should do. I thought the internet was about freedom of expression !

    So taking the last sentence I wrote, then I have absolutely no issue with bbpress not coding for new window, but I would 🙂

    Ha! Lets not hijack this topic any further, I updated my stance (or lack of) here 😉


    yoosuke
    Participant

    @yoosuke

    Thanks for two of you!
    That was familiar and interesting topic for me as a web designer!

    Well…

    Thanks to you, Mr Robin W,
    I could display ‘Website:’ part in User’s profile page!

    Now, Along with it, 2 new wishes came up to my mind.
    Would you please grant my wishes again?

    (I really appreciate from Japan! that you always help me, Mr Robin W! )

    1. When the ‘Website’ field is blank, I want it be invisible.

    Now, When it’s blank, it’s displayed like Website:_____.

    2. Is it possible to add ‘Where you live:’ part before the ‘Website:’ part?

    Showing the living place is helpful for deepening relations between users, I think…
    I wish I could add just <input> tag, neither <textarea> tag nor <select> tag.

    many thanks.

    Here is Robin’s code updated to only show the website if it is not blank:

    
    function user_profile_bbp_website_information()	{
    //this function adds the website to the profile display menu
    	$url=bbp_get_displayed_user_field( 'user_url' ) ;
    	if ( ! empty($url) ) {
    		$label1 =  $rpi_options['item1_label'] ;
    		echo "<p>" ;
    		printf ( __( 'Website : ', 'bbpress' ));
    		$url='<a href="'.$url.'">'.$url.'</a>';
    		echo $url;
    		echo"</p>" ;
    	}
    }
    add_action ('bbp_template_after_user_profile', 'user_profile_bbp_website_information') ;
    

    To add the location you want to add this, this will add the field to their profile so they can edit and update it, you then just duplicate the code from either Robin’s or mine and replace $url with $location and user_url with location:

    
    function ntwb_user_contact_methods_location( $user_contact ){
    
    	/* Add user contact methods */
    	$user_contact['location'] = __('Location');
    
    	return $user_contact;
    }
    add_filter('user_contactmethods', 'ntwb_user_contact_methods_location');
    

    Robin W
    Moderator

    @robin-w

    Thanks, Stephen ! 🙂


    yoosuke
    Participant

    @yoosuke

    Thanks to two of you Mr Robin W and Mr Stephen Edgar,
    My website is get to go at last!

    When some problems are found while running the website,
    I will come back here.

    What a wonderful place here is!

    (…see you soon.)


    wirelessvictory
    Participant

    @wirelessvictory

    Thanks steven finally got it working.


    Robin W
    Moderator

    @robin-w

    Great, I’m glad you are fixed !


    crzyhrse
    Participant

    @crzyhrse

    And a year later I must add my thanks- I also have been able to use all this so that it works nicely, including the additional location field and with both website and/or location showing in the profile only if it is filled in…

    Getting the location to show in the profile properly took a little more than the changes Steven mentions making to Robin’s code… For anyone else who might come this way here is all of it put together…

    /* Add Location field to bbPress user profile page.
     */
    function ntwb_user_contact_methods_location( $user_contact ){
    
    	/* Add user contact methods */
    	$user_contact['location'] = __('Location');
    
    	return $user_contact;
    }
    add_filter('user_contactmethods', 'ntwb_user_contact_methods_location');
    
    /* Show Location in bbPress user profile.
     */
    function user_profile_bbp_location_information()	{
    //this function adds the location to the profile display menu
    	$location=bbp_get_displayed_user_field( 'location' ) ;
    	if ( ! empty($location) ) {
    		$label1 =  $rpi_options['item1_label'] ;
    		echo "<p>" ;
    		printf ( __( 'Location : ', 'bbpress' ));
    		echo $location;
    		echo"</p>" ;
    	}
    }
    add_action ('bbp_template_after_user_profile', 'user_profile_bbp_location_information') ;
    
    /* Show website in bbPress user profile.
     */
    function user_profile_bbp_website_information()	{
    //this function adds the website to the profile display menu
    	$url=bbp_get_displayed_user_field( 'user_url' ) ;
    	if ( ! empty($url) ) {
    		$label1 =  $rpi_options['item1_label'] ;
    		echo "<p>" ;
    		printf ( __( 'Website : ', 'bbpress' ));
    		$url='<a href="'.$url.'">'.$url.'</a>';
    		echo $url;
    		echo"</p>" ;
    	}
    }
    add_action ('bbp_template_after_user_profile', 'user_profile_bbp_website_information') ;
    

    Robin W
    Moderator

    @robin-w

    Great – thanks for posting

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