Plugin Author
donmik
(@atallos)
Hi,
You cannot use this functions in members loop without sending the user_id. By default buddypress will search the hidden fields for the displayed user, but in members loop you are not displaying a single user data, so buddypress function bp_displayed_user_id() will not return any id. This is why your functions is returning an empty array.
If you want to use this function in members loop you must use like this:
bp_xprofile_get_hidden_fields_for_user(bp_get_member_user_id())
This will return an array of the ids of hidden fields for the member displayed in the loop and the current user logged in.
Hi,
thanks. I do get an array but no data is showed. There is no difference if fields are set as “nobody” or as “everyone”.
What I want to do: show the fields depenedent of visibility level and do this in the members loop.
The code I use:
<?php $hidden_fields = bp_xprofile_get_hidden_fields_for_user(bp_get_member_user_id()) ; ?>
<?php if(xprofile_get_field_data(‘field_name’) && !in_array(xprofile_get_field_id_from_name(‘field_name’), $hidden_fields)) : ?>
<?php echo xprofile_get_field_data (‘field_name’); ?>
Thanks for pointing me in the right direction.
Plugin Author
donmik
(@atallos)
Hi,
I don’t know exactly what you are trying to do, but I can say:
– xprofile_get_field_data(‘field_name’) will return nothing inside members loop because of the same reason I’ve said before about bp_xprofile_get_hidden_fields_for_user. You need to pass the user_id you want the data. Something like:
xprofile_get_field_data(‘field_name’, bp_get_member_user_id());
– If you want to display some fields, you don’t need at all to check agains bp_xprofile_get_hidden_fields_for_user(). xprofile_get_field_data only return value when current user (logged in or not) can see it depending on visibility settings so I believe your code is redundant.
Hi,
sorry, just don’t get it.
I’ve put two things in the members-loop file:
1. xprofile_get_field_data( ‘Telefoon’, bp_get_member_user_id()) ;
2. bp_member_profile_data( ‘field=Telefoon’ );
The field ‘Telefoon’ is set to show to members only.
The first one (xprofile) never shows, if I’m logged in or not. The second one (bp_member) always shows and doesn’t seem to respect visibility.
What am I doing wrong?
Plugin Author
donmik
(@atallos)
Sorry, i’m wrong, the two fields will return the value so you need to get hidden fields first.
I don’t know why in your case xprofile is not showing the same thing. In my case, it’s working… This is not really related to my plugin, maybe in buddypress forums you can find more help.