Tagged: Xprofile field length control
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.
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
BrajeshHi 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
BrajeshIf 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.
Thank you.
That makes sense.Let me check and I will update again.Regards
BrajeshHi 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
BrajeshNo, 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.