Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Changing Profile Field LABEL html?


  • ekko848
    Participant

    @ekko848

    I’m trying to add a ‘tooltip’ hover feature to some of my Profile Field labels.
    For example, one of my profile fields is ‘Twitter Handle’

    And I’m trying to modify it that it is something like….
    <abbr title="Twitter handle without the @ sign" rel="tooltip">Twitter Handle</abbr>

    I’ve found strategies to modify to HTML in bp-custom the profile field DATA using bp_get_the_profile_field_id or xprofile_get_field_data but none which seem to help me modify the profile field label.

    Any tips?
    TY!

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

  • ekko848
    Participant

    @ekko848

    Well, I was able to do this by going into wp_bp_xprofile_fields in phpmyadmin, finding my Profile Field Label… and changing the value to include the HTML.

    Also it seems, for some, since there is a 150 character limit, I may have to increase the character limit size to meet my html length.

    Thing is, I’m not sure if this is the best way to do something like this?
    Editing straight from the database seems a little iffy, I don’t want to potentially break anything.

    Any comments? Re-assurance?


    ekko848
    Participant

    @ekko848

    Anyone know if it’s safe to directly edit MySQL Database table to accomplish this?


    ekko848
    Participant

    @ekko848

    Umm.. actually, I don’t think this is the best strategy to accomplish this.
    It seems modifying the varchar contents of Profile Label doesn’t accept HTML that well.

    Close, but it seems to cut things out…

    <abbr title="Twitter handle without the @ sign" rel="tooltip" style="border-bottom:1px dotted;text-decoration:none;color:#00F303;display:inline-block;height:1.18em;">Twitter Handle</abbr>

    <abbr title="Twitter handle without the @ sign">Twitter Handle</abbr>

    So it cuts out the rel=”tooltip” which is the function that activates the style. So there must be a better way, or a workaround…


    danbp
    Participant

    @danbp

    Not sure if it is what you want, but can you test this (add to bp-custom.php) ?

    function bpex_profile_set_abbr_title( $field_value ) {
    	$bp_this_field_name = bp_get_the_profile_field_name();
    	// field name (case sensitive)
    	if( $bp_this_field_name == 'Twitter Handle' ) {
    		$field_value = strip_tags( $field_value );
    		$field_value = '<abbr title="Twitter handle without the @ sign" rel="tooltip">'. $field_value .'</abbr>';
    	}
    	return $field_value;
    }
    add_filter( 'bp_get_the_profile_field_value', 'bpex_profile_set_abbr_title' );

    ekko848
    Participant

    @ekko848

    Yes, danbp. I was messing around with code like that, but this function sets the $field_value to the DATA, not the label.

    Here’s what I mean:

    With your code–

    And on hover…

    Works well, except that it’s in data field not the profile label field.

    Here is what was happening when I was modifying HTML contents of profile field in MySQL-

    Works properly– but for some reason it’s taking out the rel="tooltip" as I mentioned in the third reply down, so is not applying tooltip style.

    We are wanting the tooltip on the Profile Label (that says ‘Twitter Handle’), and not the data, because by default, of course, the data will be empty and nothing will display. If a user hovers over Twitter Handle they will see the tooltip and know how to enter profile field properly beforehand.

    Hope that explains it.


    ekko848
    Participant

    @ekko848

    Well, I was able to do this by using the MySQL field html edit.. and for whatever reason it wasn’t including the rel=”tooltip” even though it was in the field.

    Anyways, I looked up the CSS unique selector for my Twitter Handle field and then added the following to my profile.php

    <script>
    $(".field_41 > td.label > abbr").attr('rel', 'tooltip');
    </script>

    And now it’s working properly.

    This seems like a weird way to do it, but I don’t know. I kind of figured there would be an easy way to change the HTML on a static profile field label, especially considering there is a method (as danbp described) to change html in data field.


    danbp
    Participant

    @danbp

    Glad you got it to work. But i’m wondering why you want to add this to the label (which is the field title) instead of using the field description ?

    This information is only usefull when the user fill in the field or edit it.

    You can open the one or other class file in bp-xprofile directory and read through to understand why and how each field type is set and works inside BP.


    ekko848
    Participant

    @ekko848

    I see I see. Well thank you again for the assistance.
    I think we can mark this one resolved.

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