BuddyDev

Search

[Resolved] Help needed with a PHP Snippet "BuddyPress Xprofile field length control"

  • Participant
    Level: Initiated
    Posts: 13
    romanzy on #6126

    I found a PHP snippet for BuddyPress in which I need to replace/change the applicable field name and/or ID, but I could not patch it right.

    The snipped code is http://snippetbarn.bp-fr.net/xprofile-field-length-control/

    I should replace the code $my_custom_textfield = bp_get_member_profile_data( ‘field=Brief Biography&user_id=’.bp_get_member_user_id() );
    with my applicable field below.

    Firebug provided me this field info: <dl class=”dl-horizontal field_142 field_sense-of-humor optional-field visibility-public field_type_radio”>

    I tried to patch it, but could not make it right. Can you please help me with it?

    Thank you very much in advance.

    PS: I need to extend the standard length of 150 characters of an xProfile field to something like 300 characters. If you have another solution, would be happy as well.

  • Keymaster
    (BuddyDev Team)
    Posts: 24433
    Brajesh Singh on #6127

    Hi Romanzy,
    I am sorry but I could not understand much.

    Here is a simple solution. You can put this code in members loop and change the field parameter.

    
    
    echo substr( bp_get_member_profile_data( 'field=About' ), 0 , 300 );
    
    

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 13
    romanzy on #6128

    I only wish to extend the length of an Xprofile field to 300 characters. Now it is limited to 150 characters.
    If you make for example a select box with phrases that have more than 150 characters, than the characters from 151 are not displayed.

  • Participant
    Level: Initiated
    Posts: 13
    romanzy on #6129

    I wish I could put some code in the bp-custom.php that enables that Profile Field Name Length.

  • Keymaster
    (BuddyDev Team)
    Posts: 24433
    Brajesh Singh on #6130

    Hi Romanzy,
    I am sorry but I do not understand. Where did you see BuddyPress limiting the field length. Is it happening for ll field types? I tried with text box and I don’t see any limit imposed by BuddyPress.

    If you can explain me what are you trying to accomplish in a little more detail, I will be able to help.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 13
    romanzy on #6131

    If you make a new xProfile Field, for example a radio button selection box with the following name Sense of Humor, with the following selectable lines:

    1) Laugh-at-Life Humor – I don’t take myself too seriously. When something bad happens, I’m likely to take a deep breath and look for the absurd in the situation— and then laugh about it.

    2) Bonding-in-the-Moment Humor – “We’re in this together, and isn’t it fun?” is my general outlook. I’m the type to crack a joke at just the right moment or toss a witty, lighthearted remark into a conversation before it turns too seriously.

    3) Dry/Deadpan Humor – I can deliver a hysterically funny line without cracking a smile or raising an eyebrow while everyone around me falls down laughing. But, sometimes, people don’t realize I’m kidding.

    … then you will see that the phrases are cut off as from 150 characters. So, means that users cannot read the whole phrase. I was counting the number of characters in an xProfile field, and it seems to be 150 characters maximum.

  • Keymaster
    (BuddyDev Team)
    Posts: 24433
    Brajesh Singh on #6132

    Thank you.
    That makes sense.Let me check and I will update again.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 13
    romanzy on #6133

    OK, I’m waiting you. Thank you Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24433
    Brajesh Singh on #6134

    Hi Romanzy,
    I just had a look at BuddyPress Xprofile field schema. All the code above are playing with value and not with the actual field name. In your case, you are trying to use large name.

    BuddyPress has a limitation of 150 characters for the name/type field. Please see the screenshot

    http://i.imgur.com/7gw0FUI.png

    You can modify it for your install by changing the schema. If you have access to phpmyadmin. Select your table. Go to structure tab. Then click on change link and update the length.

    It is not considered a good practice to modify the database schema but in your case, it is the simplest way to change the length of name field.

    Hope that helps.

    regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 13
    romanzy on #6135

    No, It’s not the name of the field.

    The name of the field is “Sense of Humor”.

    It’s about the content length when using a select box, for example a radio buttons, or checkboxes or drop down select box with one of the above mentioned phrases, such as:

    1) Laugh-at-Life Humor – I don’t take myself too seriously. When something bad happens, I’m likely to take a deep breath and look for the absurd in the situation— and then laugh about it.

    Do you understand me now?

The topic ‘ [Resolved] Help needed with a PHP Snippet "BuddyPress Xprofile field length control"’ is closed to new replies.

This topic is: resolved