BuddyPress – Xprofile Privacy plugin
Jun/0935
BuddyPress currently doesn’t support any kind of privacy control over profile data. Members of BuddyPress team are working on Privacy Component which will be part of some of the future releases, but until then this plugin can be helpful.
Xprofile Privacy plugin will give your users option to choose which profile data they want to share. Profile data can be public, viewable only to friends or be completely private. Users can set their privacy while editing profile or within Settings section in Profile Privacy part.
Here are some screenshots:
Installation steps:
- Download plugin: CPT BuddyPress Xprofile Privacy Plugin 0.1.1
- Go to Plugin admin section and active it
- IMPORTANT: In order to hide profile data that are not public when profile page is displayed, you will have to change one line in your BP members theme file:
profile/profile_loop.phpIf you are using default BuddyPress theme, then the file is:
wp-content/bp-themes/bpmember/profile/profile_loop.php
Replace the line:
4
<?php if ( bp_profile_group_has_fields() ) : ?>
with
4
<?php if ( bp_profile_group_has_fields() && cpt_bp_xprofile_privacy_allowed_fields() ) : ?>
- If you want to enable your users to set their privacy when editing profile data you will have to change one more file, this time BuddyPress core file.
In the file
bp-xprofile/bp-xprofile-classes.phpfind method
BP_XProfile_Field::get_edit_html()
and at the end of the method, just before return $html, add this line:
$html = apply_filters('bp_xprofile_field_edit_html', $html, $this);
I will post a ticket to ask BuddyPress team to add this hook into core, but for now this change is necessary.





20:29 on June 15th, 2009
Witch line i have to change in profile_loop.php at facebuddy-member-theme ? Thanks.
14:35 on June 16th, 2009
Hi dio.
In Facebuddy theme you also have to change line 4 of profile-loop.php file.
Instead of:
<?php if ( bp_group_has_fields() ) : ?>
place:
<?php if ( bp_group_has_fields() && cpt_bp_xprofile_privacy_allowed_fields() ) : ?>
Btw, bp_group_has_fields() is deprecated. This function still works, but it is better to use bp_profile_group_has_fields() (recommendation of BuddyPress team).
12:44 on June 20th, 2009
hey, I implemented your plugin per instructions. I get this error:
Parse error: syntax error, unexpected T_ENDIF in /home/eastlond/public_html/wp-content/bp-themes/facebuddy-member-theme/profile/profile-loop.php on line 25
Im using facebuddy theme on wordpress mu 2.7.1, buddypress 1.01
15:03 on June 21st, 2009
Hi jody.
There is a typo in previous comment, sorry. Wordpress seems to add space after <.
Instead of
< ?php if ( bp_group_has_fields() && cpt_bp_xprofile_privacy_allowed_fields() ) : ?>
it should be
<?php if ( bp_group_has_fields() && cpt_bp_xprofile_privacy_allowed_fields() ) : ?>
(beginning of the line should be <?php without space between < and ?)
06:18 on June 24th, 2009
Thanks sandra. I’ll try that and let you know if it works. It would help if I knew php better. At mo I’m just copy pasting the code around.
10:28 on June 24th, 2009
No problem.
Thanks for your interest.
15:55 on June 24th, 2009
Thank you for this tutorial.
But I still have a problem width the security of the member data: after getting all these profile fileds private I have completely logged out and on the startscreen I made a member-search. Then I got search results (still logged out) and in the result entries I got shown some of the fields prior marked as “for friends only”. How can I also fix this. Where do I find the template for the member- blog- or group-search? Does anybody know?
14:19 on June 25th, 2009
Hi Tom.
I disabled search on any field that is not public. So, if all your fields are private, search shouldn’t give you any results.
I see additional fields in “Featured Members” section though, so I guess you are referring to them.
Thanks for reporting this, I will fix it and upload new version of plugin as soon as possible.
19:48 on July 9th, 2009
Any update for the plugin, Sandra?
05:10 on July 10th, 2009
hi there. your plugin looks great. i do have one question that i couldnt figure out by looking through the code. i want to assign all the fields as private initially. this could be just as simple as having the radio button checked as if there is no value already in the database. i just couldnt find that part of the code. any help would be much appreciated. thanks
10:27 on July 10th, 2009
@Ray
No, unfortunately, no update yet. I haven’t got time to get back to this.
But, it’s not forgotten…
12:05 on July 10th, 2009
Hi jason.
I made a very small change in a plugin to set radio buttons to some default value. So, first step would be downloading plugin again.
Default for plugin is to set all fields to be public. If you want to set them to be private then you will need to change line 28,
define( ‘CPT_BP_XPROFILE_PRIVACY_FIELD_DEF_VALUE’, ‘2′ );
to
define( ‘CPT_BP_XPROFILE_PRIVACY_FIELD_DEF_VALUE’, ‘0′ );
And that should be it. Let me know how it worked out.
03:08 on July 11th, 2009
Hi Sandra,
Thanks for noting that code for setting default values.
Is it possible to set default values for the “Base” fields only?
05:01 on July 11th, 2009
Thanks…this is great! You’ve provided something that I’ve been looking for…great work!
16:30 on July 11th, 2009
Hi..Now that I’ve tried this, it looks like it’s breaking another custom plugin I’ve got..wondering if you do custom work that might do a work around for this
15:18 on July 12th, 2009
Hi, thanks for the great plugin, can’t get it working though! Have installed and activiated it fine, but when I log in and go to other accounts that I’m not friends with, I can still access it and see everything. I haven’t installed the section to allow users to adjust settings but I have adjusted the default setting as above to make the default private – still nothing looks like its changed, I can still access profiles that I’m not friends with – what I am doing wrong please?
Thanks, Mr C
10:45 on July 13th, 2009
@Ray
No, that is not possible. This plugin is made just to provide basic privacy control, until BP team writes privacy component. That is why it is so simple, with just few options. If I see there is a lot of interest, I might expand it a bit.
@Allen Weiss
Can you give me more details about this problem?
Well, I can try.
11:36 on July 13th, 2009
@Mr C
This plugin is made to give users privacy control of their profile data. No matter if you haven’t enabled privacy control in profile, users can still go to Settings area and change their privacy.
Anyway, if you first activated plugin as it was and then changed value of CPT_BP_XPROFILE_PRIVACY_FIELD_DEF_VALUE, then in your database privacy field default value is set to public. New settings (private) will be just a default value, preselected when user edits his profile. If user doesn’t change his settings, profile data will be public. To fix this to work as you like, you can run these queries on your database…
This will set default value of table field to private:
alter table wp_bp_xprofile_data alter column privacy_level set default 0;
This will set all profile data to be private.
update wp_bp_xprofile_data set privacy_level=0;
As I said, this plugin lacks of settings because it is meant to be a temporary solution until BP privacy component arrives.
16:35 on July 13th, 2009
Hi Sandra
that’s ok..I found out how to make this work.
Thanks
Allen
19:32 on July 14th, 2009
Hey.
Thanks for the plugin. But is there anyway to not show the privacy options at the name field? Is seems wierd that you can toggle that, as the users name will still be shown anyway no matter what you choose.
Otherwise a great plugin!
12:42 on July 15th, 2009
Hi Mikael.
Yes, you are right… Maybe I can skip adding privacy control on name field or add some switch.
Thanks for suggestion.
18:24 on July 24th, 2009
Hi Sandra!
Great plugin! Exactly what I was looking for!
One question, if you put the Name field to prive, does it also hide that name from Activity feeds and Wire posts etc? Or does it just hide in the Profile page?
Thanks for a great plugin!
Erwin
23:54 on July 25th, 2009
Bin gerade nicht in der Stimmung auf Englisch
Steht der Code explizit unter der GPL? Wenn ja, kann das Plugin in den Core von BuddyPress einfließen.
Gruß Dennis
10:24 on July 27th, 2009
Hi Erwin.
No, name field can’t be private/hidden in other BP components. Actually, Mikael from one of the previous comments made a good point, it would be good to remove privacy control from the name field because it makes confusion like it is now.
I don’t have much time to work on this now, but I will try to change it in the next couple of weeks so at least it will be clear to users that name is public data.
I hope that works for you.
10:36 on July 27th, 2009
Hi Dennis.
Sorry, I don’t speak German. But, I translated your comment with Google translate so I have an idea what is your question.
Sorry if answer is not what you are looking for.
Yes, plugin is under the same license the BuddyPress is. It is not in the core because BP team is working on privacy component that will enable all sorts of privacy control so this plugin is a temporary solution until they release core component.
20:50 on August 12th, 2009
Hello Sandra,
is there any way to control the activity stream, friends, etc as well? that would be much appreciated!
Thanks,
Reiner
09:09 on August 20th, 2009
Hi Sandra,
Great plugin! Is there anyway to ‘choose’ the base information that can be changed? i.e. set a field that users cannot change???
Thanks.
Robin
16:05 on August 21st, 2009
Hi,
I installed your plugin, customized it (look and feel). It is great. It shows up every where (on profile edits, even on registration page). But, I still cannot get it it to work, i.e., the fields are visible to every one! Irrespective of what i do
Any Ideas?
16:28 on August 21st, 2009
Just a sample from the wp_bp_xprofile_data
44 1 9 Oracle 2009-08-21 08:15:11 0
45 3 9 Master 2009-08-21 08:15:11 0
46 753 9 Male 2009-08-21 08:15:11 0
Look at the last field, it is all set to 0, still I am able to see all the information via
http://www.oraclepronet.com/members/oracle
These are just test users. Has it got something to do with caching? I have cleared client side caching and dont have anything but a css cache tool on server
kindly advise
ramesh
17:36 on August 21st, 2009
Sorry for posting so frequently…but i am working on a deadline to release this site
My observations
1. Updates to the table are happening properly, via update profile form (Queried database after changes).
2. Fields are still displayed irrespective of the value of privacy level in the table
Best Regards
Ramesh
12:32 on August 27th, 2009
I have added the code to add the login boxes on the profile, however. I am using a theme from Avenue K9 and there is no area that allows me to add this:
If you want to enable your users to set their privacy when editing profile data you will have to change one more file, this time BuddyPress core file.
In the file
bp-xprofile/bp-xprofile-classes.php
find method
`code`BP_XProfile_Field::get_edit_html()`code`
and at the end of the method, just before return $html, add this line:
`code`$html = apply_filters(‘bp_xprofile_field_edit_html’, $html, $this);`code`
22:37 on September 29th, 2009
I have Buddypress 1.0.3, and WPMU 2.8.4a. I can’t find this line BP_XProfile_Field::get_edit_html() in the core file bp-xprofile/bp-xprofile-classes.php . Please help!
10:21 on September 30th, 2009
Functionality around xprofile data has changed significantly. In current 1.1 RC there is no more get_edit_html() method. But, as I saw on BP trac, in 1.0.3. version there is still this method in line 383. You can see it here:
http://trac.buddypress.org/browser/tags/1.0.3/bp-xprofile/bp-xprofile-classes.php
Anyway, my plugin won’t work on 1.1 (from obvious reasons
) and since privacy component from Jeff Sayre will be out soon and BP will have it’s own core privacy management in 1.2 version, I haven’t planed on maintaining this plugin, except if there are enough requests for it.
You can see here about Jeff’s plugin:
http://buddypress.org/forums/topic/buddypress-privacy-component-an-update
10:10 on January 28th, 2010
Just to give an update: We have currently discontinued development of this plugin; we’ve switched to the Buddypress Privacy Component by Jeff Sayre ourselves. See http://jeffsayre.com/2009/12/05/buddypress-privacy-component-released/ for more details.