Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get rid of autolinking on profile fields


  • karthik_kastury
    Member

    @karthik_kastury

    Hey how do you get rid of autolinking of profile fields on buddypress.. On my network people enter all kinds of stuff on the profile, i want the clickable links for search only for some profile fields and not all of them by default.

    who would search for mobile number in the profile?

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

  • fishbowl81
    Participant

    @fishbowl81

    very simple

    remove_filter( ‘bp_the_profile_field_value’, ‘xprofile_filter_link_profile_data’, 2);

    That removes the autolinking

    I have developed a nice plugin (now a pair) which changes profile values rendering depending on the name of the group. I have not yet released the code, as I’m offering it as beerware.

    Here is my profile on my beta site:

    http://gorgeousgamers.com/beta/members/bradmkjr/

    I made the social details, normally clickable so people can enter myspace, facebook, or personal sites.

    I also made a fun mp3 player plugin to allow people to suggest music for their profiles and listen to samples.

    Brad

    http://gorgeousgamers.com/beta


    Mike Pratt
    Participant

    @mikepratt

    Brad – nicely done. a few beginner questions:

    1. where are you applying this filter? I assume 2 was the field_id?

    2. For the web site link (non-bp link) in your example, do users need to merely enter a valid url? just http://www.example.com or what, specifically – I will need to steer them.

    3. How would you go about configuring a mailto: link (assuming they were safe behind the login walls form scrapers


    fishbowl81
    Participant

    @fishbowl81

    This post maybe a little more clear, as it has a full working music player.

    https://buddypress.org/forums/topic.php?id=604#post-3382

    #1, the 2 is priority of the filter.

    #2, I have been lazy and just made everything inside of the “social details” group active links. In the future I maybe validating them with some regular expressions or substring checking.

    #3, check for an @ and at least 1 period in the string and no spaces? There are some very complex regular expressions which can validate e-mail addresses, but regular expressions are slower then substrings.

    Brad

    http://gorgeousgamers.com/beta


    gpo1
    Participant

    @gpo1

    fishbowl81, I like your member theme.which file did you use to change the top bar ie to red & black.

    That is how did you do it?

    And also can you adapt it for lastFM widget?

    Link for lastfm api

    http://apps.sourceforge.net/mediawiki/phplastfmapi/index.php?title=Usage


    karthik_kastury
    Member

    @karthik_kastury

    fishbowl81, thanks for the help.. am not sure of where exactly to put that code.. chk out my profile @ http://ignitte.in/members/admin/profile

    over here i would like everything in the contact group to be delinked except for the URL.. hw do i go about this?


    yu
    Participant

    @gerbilo

    and other question – how to check user added info posted in this extra fields? cause i just saw hundreds spaces in ‘link’ field…


    yu
    Participant

    @gerbilo

    i’ve found this function –

    function xprofile_filter_link_profile_data( $field_value, $field_type, $field_id ) {
    if ( $field_type == 'datebox' )
    return $field_value;

    if ( !strpos( $field_value, ',' ) && ( count( explode( ' ', $field_value ) ) > 5 ) )
    return $field_value;

    $values = explode( ',', $field_value );

    if ( $values ) {
    foreach ( $values as $value ) {
    $value = trim( $value );

    if ( count( explode( ' ', $value ) ) > 5 )
    $new_values[] = $value;
    else
    $new_values[] = '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/?s=' . $value . '">' . $value . '</a>';
    }

    $values = implode( ', ', $new_values );
    }

    return $values;
    }
    add_filter( 'bp_the_profile_field_value', 'xprofile_filter_link_profile_data', 2, 3 );

    so EVERY field is ‘link’ field.. i think this is not so good ;/

    next stape i think should be creation of new field_types, and applying filters to this field_types in this function. but where are this types and how to create new ones i don’t know..


    westpointer
    Participant

    @westpointer

    For now, I simply commented out the line

    add_filter( 'bp_the_profile_field_value', 'xprofile_filter_link_profile_data', 2, 3 );

    on line 14 of bp-xprofile/bp-xprofile-filters.php. The current fn simply makes way too many words into search hyperlinks.


    nandopax
    Participant

    @nandopax

    Great! It works!


    takuya
    Participant

    @takuya

    When will this be fixed officially? Commenting out the add_filter removes all the auto linking functions. I only want one section without auto linking.


    Greg
    Participant

    @rebootnow

    I also wanted to remove the linking in the profile fields, so I added the following line (given above by Fishbowl81) to bp-custom.php, which is in the “plugins” directory.

    remove_filter( 'bp_the_profile_field_value', 'xprofile_filter_link_profile_data', 2);

    The profile fields still have the links though. Is there something special I need to do aside from putting the line in bp-custom.php?

    UPDATE: I believe that bp-custom.php should actually go in “mu-plugins”. Also, I did add the php script tags (<?php and ?>) around my code in this file. Still the links appear.


    Greg
    Participant

    @rebootnow

    UPDATE 2: I see that in 1.02 the filter is added to ‘bp_get_the_profile_field_value’, so I changed this in the line above, but still the links hang in there.


    Jeff Sayre
    Participant

    @jeffsayre

    I believe that bp-custom.php should actually go in “mu-plugins”

    No. bp-custom.php goes in /plugins/. See line 9 of bp-core.php.


    Greg
    Participant

    @rebootnow

    Thanks Jeff.

    So to sum up, I have the following line in “plugins/bp-custom.php”

    remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2 );

    But the links still appear on my profile page. I can remove the links by commenting out line 15 in bp-xprofile-filters.php, but I’d love to get this right without the mod to a core file.


    Jeff Sayre
    Participant

    @jeffsayre

    @Reboot

    Okay, thanks to Burt for waking me up enough in IRC to point out my errors, here’s what you need to place in your bp-custom.php file:

    <?php
    function remove_links(){
    remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2 );
    }
    add_action( 'plugins_loaded', 'remove_links' );
    ?>

    That should work.

    I’m going to get some sleep now.


    Greg
    Participant

    @rebootnow

    Jeff, fantastic, this works.

    Just to make sure I understand *why* it works… by just running the remove_filter() function in bp-custom as I was doing earlier, I guess it was running before the filter was added. What you are doing is delaying the remove_filter() call until all plugins are loaded.

    Do I have that right?

    Thanks very much.


    Gianfranco
    Participant

    @gian-ava

    I’d like to remove auto links for profile fields. I retrieve their values and dispaly it on a sidebar, but don’t find any use in linking any word to nothing.

    That is really an annoying feauture that should be turned on and off at will.

    The above code doesn’t seem to work anymore with the latest version of BP.

    Is there a way to turn auto links off?


    r-a-y
    Keymaster

    @r-a-y

    @gian-ava

    Please refrain from bumping similar threads.

    You also posted in:

    https://buddypress.org/forums/topic/words-in-user-profile-some-are-linked-some-are-not

    All replies should be made in the above thread.

Viewing 18 replies - 1 through 18 (of 18 total)
  • The topic ‘How to get rid of autolinking on profile fields’ is closed to new replies.
Skip to toolbar