I think you need to look at what @DJPaul said. If your function always returns true then you’re always going to output something, even if that something is blank.
function custom_xprofile( $field ) {
echo bp_custom_get_member_list_xprofile_data( $field );
}
That echo will always return something. You need to dig into bp_custom_get_member_list_xprofile_data and see if there’s a way to determine if $field exists.
It looks like if you go and start building profile groups as they come in your head, and then for some reason you want to display them in a more logical order within a profile page, you just can’t do so.
The order is the same as in the admin, when you first created them, and you stuck with it forever.
Or is there a way to change the order?
And another thing I am trying know (Question #2) is if it is possible to use a conditional statement to check if more than 1 group has fileds that has been filled in and return something accordingly:
<?php if ( bp_has_profile('profile_group_id=9') || bp_has_profile('profile_group_id=7') ) : ?>
<?php while ( bp_profile_groups() ) : bp_the_profile_group(); if ( bp_profile_group_has_fields() ): //groups loop ?>
<div id="widget1">
(stuff from group 9)
(stuff from group 7)
</div>
<?php endif; endwhile; ?>
<?php endif; ?>
After experimenting, I couldn’t make it work.
I need that because in my design I’d like to output a “Personal stuff” widget that has a graphic title and background, and it should display only if some fields from groups 9 and 7 are filles in, otherwise it should’t.
Is that achievable?
That is a guru question, isn’t it?
Thanks jivany. I corrected that.
However, that is not the source of the porblem.
I am trying to achieve different things.
One is to say, if that field is not filled in, don’t output this block.
Something like:
<?php if (custom_xprofile('About me') ) : ?>
<h3>About me:</h3>
<?php custom_xprofile('About me'); ?>
<?php endif; ?>
But as simple as it is, sometimes I am lost on PHP basics.
Nah, you can leave semi-colons off the end of lines when it’s used like that. Good spot though. It’s because your function just retrieves the value from the database, and if it’s blank, then it’s blank. Problem is, you are printing the <h3> regardless.
You’re missing a semi-colon after the custom_xprofile call. That will likely bugger up PHP and might be the source of your issue.
Question #1:
I am using the following technique to get single profile values for members pages.
This in “bp-custom.php”:
// Get single value from profile fields
function custom_xprofile( $field ) {
echo bp_custom_get_member_list_xprofile_data( $field );
}
function bp_custom_get_member_list_xprofile_data( $field ) {
global $site_members_template;
return xprofile_get_field_data( $field, $site_members_template->member->id );
}
And this is the snippet for an “About me” widget:
<?php if ( bp_has_profile('profile_group_id=7') ) : ?>
<h3>About me:</h3>
<?php custom_xprofile('About me') ?>
<?php endif; ?>
I get the value right, but the problem is that on members profile that DIDN’T fill in the “About me” field, the heading (h3) “About me” still shows. Not the value, just the heading.
Is there something wrong in my conditional statement?
Here’s my structure for the sidebar (I want some widgets on all pages and profile fields widgets on members pages):
<?php if (!bp_is_member()): //if not profile ?>
// widgets
<?php else: ?>
<?php if ( bp_has_profile('profile_group_id=7') ) : ?>
<h3>About me:</h3>
<?php custom_xprofile('About me') ?>
<?php endif; ?>
// other widgets
<?php endif; ?>
One thing that the code doesn’t do is turning off auto links for url’s.
I want members to fill some fields with their personal social profiles links: Facebook, Twitter, Personal Homepage.
I’d like to link it from the words: “Facebook”, “Twitter”, “Personal Homepage”, without having http://facebook.com/user, ect.
Now, I tried something like this within the profile fields loop:
<li><a href="<?php echo bp_the_profile_field_value() ?>"><?php bp_the_profile_field_name() ?></a></li>
But of course it messes everything up because the function “bp_the_profile_field_value()” generates a <a href="...">
itself.
Is there a workaround for this?
To answer your second question, no, there’s no plugin available to add custom fields to groups (that I’m aware of).
@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.
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?
This is a ‘Field Group’ or fieldset for the profile. It is not a way to create extra fields for groups.
@Mariusooms
This can be added, we will try to include it in next release (before that we’re waiting for some more feedback).
I guess best would be to check if user is coming from some outside URL, if so – to redirect him to preferred language, otherwise let him switch languages as usual.
@Sanny
Thanks for valuable feedback.
BP is not wrapping extra profile fields (title and description) in textdomain – you can’t get it translated (for now). We will try to add support for this – to register extra field’s titles and labels (descriptions), so it can be translated via WPML’s ‘string translation’.
Just rename those fields in the Profile Field Setup in wp-adminb
Hi jozik,
I’m dealing with a big problem regarding Buddypress multlingual: no matter what I do, I can’t figure out how to make the BP Registration page multilingual, since the Registration/ Sign Up Fields are dynamic I guess, I don’t know how to translate them from EN to IT once I set them up??? Also because at the moment my Italian version is a mixture of the following fields to name just the first 2 that can’t be translated:
Dettagli Account (obbligatorio) –> is fine
Indirizzo Email (obbligatorio) –> is fine
Scegli una Password (obbligatorio) –> is fine
Conferma Password (obbligatorio) –> is fine
Dettagli Profilo –> is fine
Name (obbligatorio) –> here its starts since Name is set in “general settings”
Last Name (obbligatorio) –> and Last Name was added by me in “profile field setup”
…
.
.
Do you have an idea how to solve this problem? Or am I missing something? Please help!
Thanks & Grazie!!!
Sanny
(my site: WPMU 2.9.1, Buddypress 1.1.3, WPML 1.7.1. & Buddypress Multilingual 0.9.2 )
Hey everyone,
I’m dealing with a similar problem: no matter what I do, I can’t figure out how to make the BP Registration page multilingual, since the Registration/ Sign Up Fields are dynamic I guess, I don’t know how to translate them from EN to IT once I set them up??? Also because at the moment my Italian version is a mixture of the following fields to name just the first 2 that can’t be translated:
Dettagli Account (obbligatorio) –> is fine
Indirizzo Email (obbligatorio) –> is fine
Scegli una Password (obbligatorio) –> is fine
Conferma Password (obbligatorio) –> is fine
Dettagli Profilo –> is fine
Name (obbligatorio) –> here its starts since Name is set in “general settings”
Last Name (obbligatorio) –> and Last Name was added by me in “profile field setup”
Does anyone have an idea how to hack the register.php? Or am I missing something? Please help!
Thanks & Grazie!!!
(my site: WPMU 2.9.1, Buddypress 1.1.3, WPML 1.7.1. & Buddypress Multilingual 0.9.2 )
@mrjarbenne – Good point.
To set a default privacy level that ensures no one inadvertently exposes info, open the file simple-buddypress-privacy.php using a basic plain text editor like Notepad on Windows (do not use Microsoft Word to edit code). Find this line near the top somewhere:
define( ‘CPT_BP_XPROFILE_PRIVACY_FIELD_DEF_VALUE’, ‘3’ );
Change the number 3 to 0 (zero). Save the file, then upload the plugin and activate it. By changing 3 to 0 the plugin will default to making all profile fields invisible to everyone except the profile owner. Then students can edit their profile and intentionally choose which fields to expose.
That’s the quick fix for your particular situation.
Of course that still doesn’t allow you to force any permanent settings since students ultimately get control. But I see your point – I just don’t agree with it entirely even in the case of elementary school students.
As a parent, I advocate teaching along with careful monitoring – the two go hand in hand. Of course being taught involves the student making mistakes – granted. So, if you really want to ensure that no student exposes sensitive information then consider not providing a mechanism for such information to be put into a Web site – particularly since unless you put those computers in a vault at night then you have no idea who is really accessing that information nor when it is accessed. For example, what if your school is burglarized and the computer(s) stolen? Or if your site is not hosted in the school itself, then you have no total control whatsoever over what happens to the information in the site.
Wondering if there is a plugin for this, or for advice on how easily it might be put into play. After users activate their accounts, and work through entering all of the required Profile fields, I want to take them through a series of (five or six) statements/terms of service, that would appear in sequence before the user is able to move forward.
A bit of background. I’m using BP in an elementary school, and I’m getting ready to invite some other schools into the fray, so I won’t be in the classroom to direct appropriate use, and I’m tired of the garbage that new users spew on the activity stream before they take a moment to recognize the mood/climate of the network. I want them to do a bit of a “quiz” to ensure that they understand what is expected on the site. Remember that these are 9 and 10 year olds, so to kick and ban doesn’t provide that “teachable moment” I’m looking for.
Is there a way to do this, or should I just add required Profile Fields, then use the BP Profile Privacy plugin to set these fields as only available to be viewed by the admin.
https://wordpress.org/extend/plugins/bp-profile-widget-for-blogs/
– enables blog admins to show their BuddyPress avatar with link to BP profile page plus own xprofile fields
I have a request that would make it easier for visitors to find members (or groups, blogs, forums, etc).
The “search anything” box in the members directory is great, but not necessarily intuitive. It would be great to have additional drop-down menus to search by select profile fields.
For example, I have a profile field for what State a member is in. It would be great to be able to filter members by state.
These extra boxes could be tied to profile fields and therefore completely customizable.
I run a real estate community and one of the most common complaints i hear is that it’s not intuitive to search for members by location.
This should a very simple problem and probably even a php question… One of my profile fields is called:
Noah’s Ark
(see http://farmvillechicken.com/members/admin/profile/)
However, if I try to get the value for this it can not be found. I also tried (backslash) ’ but that also does not seem to work.
Uhm… so now my workaround is substr( ) with the first four characters to match the word “Noah”……. not really good. I just want to get the value of this Profile field. So addslashes() does not seem to work.
p.s. I also noticed another issue: when clicking the link above it returns to the main site instead of the profile?
Hi,
I would like to create a profile field from a script.
This profile field is a checkbox and I need to add a default option too.
I can create the fields, but can’t set the option as child of the checkbox.
Any idea ?
How can I do ?
This do not work.
$checkbox = new BP_XProfile_Field();
$checkbox->group_id=$location_group_id;
$checkbox->type=’checkbox’;
$checkbox->name=__(‘Location Marker’,’bp-maps-profile’);
$checkbox->field_order=$key;
$checkbox_id = $checkbox->save();
if ($checkbox_id) {
$option = $checkbox;
$option->parent_id = $checkbox_id;
$option->type=’option’;
$option->name=__(‘Geolocate this address’,’bp-maps-profile’);
$option->option_order=1;
$option->order_by=’default’;
$option->is_default_option=true;
$option_id = $option->save();
}else {
$errors->add(‘bp_maps_profile_field_creation’,__( ‘Error while trying to create the map field’, ‘bp-maps-profile’ ));
return false;
}
+1
If plugin can also import/export Resumees (CV’s) maked with x-profile fields (with a map fields from linkedin to bp option) will be gold.
issue could only be the Email Domain setting on the Facebook application, as far as I know
That sounds like it to me. Have you checked that Greg? I don’t think it’s anything Buddypress-specific.
Andy’s version of the plugin works brilliantly for me, including custom queries – except a query for xprofile fields, haven’t figured that out yet.
@r-a-y: Didn’t see that one, and after hunting around for a while I decided to stop hunting and make one work. I read and write code pretty fast so for me making one work is faster than hunting in this case.
Anyway, the one I released allows for only showing info to logged in users. The plugin you linked doesn’t do that. Plus I don’t see any reason not to give the user total control over their profile since it’s their info (thus no need for a setting to “Let user decide” )
Also, the one you linked has controls in the admin panel that govern a user’s profile. So if you want to let a user control their own settings you have to set every profile field to “Let User Decide” which is fine, until you add new profile fields and forget to go back and make that adjustment for the new fields.
I like the no maintenance route of just automatically letting the user take total control of their info.
Thanks for the link though.
And for clarity’s sake, I didn’t write the original code. I simply modified it to work with BP 1.2 and added a few features.
As for UI, there’s no need for an admin interface so none exists. To handle display of the field controls you have to modify CSS to work with your particular template unless it works out of the box Ok for you. Same as any plugin that puts content on a site.