Skip to:
Content
Pages
Categories
Search
Top
Bottom

Links in Bio of Profile fields (Bug)


  • Michael Bryner
    Participant

    @utahman1971

    Links showing

    As shown in image, the links are added by BuddyPress. They are not added by me. Ever since I added the BIO field for profiles, it has done this. I don’t know for sure if that is a bug or what, but when clicking on it, it just takes you to that members page. It looks as if BuddyPress is tagging certain words in the field to link to the user page. If that is what it is meant for, then sorry for this thread. If it isn’t, then this is a bug.

    Not sure where to put this.

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

  • danbp
    Moderator

    @danbp

    hi @utahman1971,

    this is the default behave of extended profile fields. Also it’s very handy, as those links became searcheable keywords. This let users click and find other entered same words.

    That said, a bio is generally more personnal, so those links maybe less important…

    Here’s a snippet (bp 2.0.1 +) you can add to bp-custom.php. It let’s you selectively disable those automated linking from some fields and let some other in place.

    function my_xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) {
        // Access the field you are going to display value.
        global $field;
        // In this array you write the ids of the fields you want to hide the link.
        $excluded_field_ids = array(2,6,7);
        // If the id of this $field is in the array, we return the value only and not the link.
        if (in_array($field->id, $excluded_field_ids))
    	return $field_value;
    	
    	if ( 'datebox' == $field_type )
    	return $field_value;
    	
    	if ( !strpos( $field_value, ',' ) && ( count( explode( ' ', $field_value ) ) > 5 ) )
    	return $field_value;
    	
    	$values = explode( ',', $field_value );
    	
    	if ( !empty( $values ) ) {
    		foreach ( (array) $values as $value ) {
    			$value = trim( $value );
    			
    			// If the value is a URL, skip it and just make it clickable.
    			if ( preg_match( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $value ) ) {
    				$new_values[] = make_clickable( $value );
    				
    				// Is not clickable
    			} else {
    				
    				// More than 5 spaces
    				if ( count( explode( ' ', $value ) ) > 5 ) {
    					$new_values[] = $value;
    					
    					// Less than 5 spaces
    				} else {
    					$search_url   = add_query_arg( array( 's' => urlencode( $value ) ), bp_get_members_directory_permalink() );
    					$new_values[] = '<a href="' . $search_url . '" rel="nofollow">' . $value . '</a>';
    				}
    			}
    		}
    		
    		$values = implode( ', ', $new_values );
    	}
    	
    	return $values;
    }
    
    /**
     * We remove the buddypress filter and add our custom filter.
     */
    function remove_xprofile_links() {
        // Remove the old filter.
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
        // Add your custom filter.
        add_filter( 'bp_get_the_profile_field_value', 'my_xprofile_filter_link_profile_data', 9, 2);
    }
    add_action('bp_setup_globals', 'remove_xprofile_links');

    If you want to deactivate completely profile fied links, you can use this function:

    function bpfr_remove_xprofile_links() {
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
    }
    add_action('bp_setup_globals', 'bpfr_remove_xprofile_links'); 

    Michael Bryner
    Participant

    @utahman1971

    Actually I already fixed it by adding a bp-custom.php with

    function bpfr_remove_xprofile_links() {
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
    }
    add_action('bp_setup_globals', 'bpfr_remove_xprofile_links');

    in it, in the plugins section. So thanks for trying to help.


    Michael Bryner
    Participant

    @utahman1971

    This one is six months old and never closed and is resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Links in Bio of Profile fields (Bug)’ is closed to new replies.
Skip to toolbar