Hi,
I am trying to create a members-only site with WordPress V3.6.1 and although I have made some progress, I have some problems.
I have 3 plugins installed, and am not sure if they are conflicting, superfluous or complementary. In addition to Buddy Press v1.8.1 and Buddy Press Login Redirect v 2.1, I have WordPress Access Control V3.1.4 activated. I have also tried a number of others which I have de-activated, but am not sure to what extent, if any, some of the data I am seeing is a legacy of those plugins.
At present I seem to have discrepancies between the user profile as shown on the WP admin dashboard and the members profile on the site, eg the site shows the fields created using the WP Dashboard Users/Profile Fields (which I assume is a BP process); this includes Address and Notes Fields. However the profile accessed through the Dashboard/All Users Edit User does not show these, but does include fields named First Name, Last Name, Nickname(required) & Biographical Info, which I suspect are hangovers from one of the other plugins which I tried. I have added these to the Profile Fields, but the data displayed in two views of the user profile doe not match, so I imagine that the new fields have different names to the originals. In fact having inspected the two pages, I see that what is “last_name” on the dashboard is “field_7” on the User profile setup.
I imagine that editing the user-edit.php should solve the problem but I am not confident that I could to this and feel that it should not be necessary each time I update the user profile set up, so there must be a simpler solution. Can you please suggest how I get the wp-admin/user-edit form to align with the wp-admin/ profile setup?
I would also like to provide the option to display a member’s email address on the profile page, but at present the only way I can find of doing that is to create a second email field, but asking members to enter it twice does seem unprofessional.
I hope that makes senses and that someone will be able to suggest a simple solution.
I would like to create a section where people can sign in and answer questions and add their image and then have people see their answers.
@cortttt Sure. Use BuddyPress Extended Profile Fields to highlight the best of your community https://codex.buddypress.org/buddypress-components-and-features/extended-profiles/
Make sure that Extended Profiles is checked in wp-admin Settings > BuddyPress > Components
At the top of the sections would be a running total…total years lost to illness
Check out https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/ and then customize the plugin to include the running total years lost to illness or use/rename birthday field
Hi,
I am trying to create a message in the xprofile view tab, to show only if certain fields are empty, but I can’t get it to work whatever i do. i’m placing the following code inside the profile loop:
<?php if ( !bp_field_has_data('field_id=2') ) {
echo "Please tell the community a little bit about yourself by filling out the form on the 'edit' tab above.";
} elseif ( !bp_field_has_data('field_id=3') && !bp_field_has_data('field_id=4') ) {
echo "There's nothing here! spruce up your profile by adding content via the 'edit' tab above.";
} else {
echo "";
} ?>
I’d be grateful if someone could point me in the right direction. I’ve trawled the internet for a solution, but i’m getting nowhere.
Thanks,
Yukon
Hi,
I find it a bit troubling that BP xprofiles doesn’t support disabling fields, because if you use an xprofile field for people to agree with your terms and conditions, then they can agree and then edit the field and disagree. Could you make it so people can disable the field? This would be helpful for everyone.
Thank you.
Thanks @henrywright-1 and @shanebp
Works a treat 🙂
@henrywright-1
Don’t initialize $i as a string if you’re going to use it as an integer.
if ( $items = bp_get_profile_field_data( array( 'field' => 'Budget' ) ) ) {
$i = 0;
foreach ( $items as $item ) { ?>
<div id="size-<?php echo ++$i; ?>">
<?php echo $item; ?>
</div>
<?php }
}
Ah I see what you’re trying to do.
$i = '1';
if ( $items = bp_get_profile_field_data( array( 'field' => 'Budget' ) ) ) {
foreach ( $items as $item ) { ?>
<div id="<?php echo 'size-' . $i; ?>">
<?php echo $item; ?>
</div>
<?php $i++; ?>
<?php }
}
Hmm ok thanks @henrywright-1
On the front end I get:
item-1 £500k-£2m
item-2 £2m+
The HTML generated is –
<div id="size500">
item-1 £500k-£2m
</div>
<div id="size500">
item-2 £2m+
</div>
How can I make those divs unique?
A unique ID is easy enough, just use the loop to output a unique value. e.g.
$i = '1';
if ( $items = bp_get_profile_field_data( array( 'field' => 'Budget' ) ) ) {
foreach ( $items as $item ) { ?>
<!-- put what you want here -->
<?php echo 'item-' . $i; ?>
<?php echo $item; ?>
<?php $i++; ?>
<!-- put what you want here -->
<?php }
}
Quick question @henrywright-1 – any way to give each of those that are spat out a unique id?
Or do they have to have the same HTML around them?
Ideally, each of the items are wrapped different id – e.g.
<div id="size500">£500K</div>
@henrywright-1 it’s added in /wp-admin/users.php?page=bp-profile-setup – Profile Fields under the Users menu in WP Admin.
Your code works, thanks..!
So I can add html into those spaces, and each item is now separated by html…I think that should do it. Thanks so much for the support Team Buddypress 🙂
Is budget a field that you’ve set up under WP Admin > Profile Fields? and is it of type ‘checkbox’? also are you displaying the values on the user’s profile page? if yes to all of these then this should work:
if ( $items = bp_get_profile_field_data( array( 'field' => 'Budget' ) ) ) {
foreach ( $items as $item ) { ?>
<!-- put what you want here -->
<?php echo $item; ?>
<!-- put what you want here -->
<?php }
}
Note: I’ve amended the code so you can insert HTML a bit easier
Hi @henrywright-1
Thanks for the idea.
Pasting that in (exactly as it is) doesn’t return anything for Budget.
How do I add the HTML I want into:
// put whatever you want here
Cheers
Ian
Hi @applegateian – I think the problem might be the snippet you’re using to output the data string.
try doing something like this:
if ( $items = bp_get_member_profile_data( array( 'field' => 'Budget' ) ) ) {
foreach ( $items as $item ) {
// put whatever you want here
echo $item;
// put what you want here
}
}
Note: I haven’t tested.
Not sure it’s a custom hack…
In WordPress admin, I go to Profile Fields
Then, I have three profile groups in there. The third one is where this budget field sits.
It’s only available to certain user types, which is why it’s in a separate profile group.
However, as far as I know @bphelp – none of this is custom or a hack, this is standard BP functionality? Then using this snippet to show the output on the front end:
<div id="profileProjectSize">
<?php
$data=bp_get_member_profile_data(array('field'=>'Budget'));
echo $data;
?>
</div>
@applegateian
Maybe I am missing something here! Did you add those fields in the dashboard, or was it some custom hack?
That’s what is strange @bphelp – when I inspect element in Chrome, there are simply no tags around the checkboxes on view profile:

@applegateian
If your on the view profile page and you are inspecting with dev tools you should see a tr class with the field_ID followed by td class label and td class data. You should be able to use those to your advantage.
Sorry, meant to put @bphelp
Hi there
Thanks @bp-help for the response. I’m not inspecting on the edit profile page, no, because I am displaying the ‘budget’ information for site visitors.
It’s on the view profile page ( /profile) that I am showing this field using:
<div id="profileProjectSize">
<?php
$data=bp_get_member_profile_data(array('field'=>'Budget'));
echo $data;
?>
</div>
If I go to edit profile page, I can see the following for a checkbox:
<label><input type="checkbox" name="field_229[]" id="field_758_0" value="£0-£100k"> £0-£100k</label>
How would I get that unique id to show on the view profile page where I am using it?
@applegateian
I just created a checkbox called “Sign up for our newsletter” and this is what is return when I inspect the element:
<div class="editfield field_21 field_sign-up-for-our-newsletter">
<div class="checkbox">
<span class="label">Sign up for our newsletter </span>
<label><input checked="checked" type="checkbox" name="field_21[]" id="field_22_0" value="Yes"> Yes</label> </div>
<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-21">
This field can be seen by: <span class="current-visibility-level">Anyone</span> <a href="#" class="visibility-toggle-link">Change</a>
</p>
<div class="field-visibility-settings" id="field-visibility-settings-21" style="display: none;">
<fieldset>
<legend>Who can see this field?</legend>
<ul class="radio"><li><label for="see-field_public"><input type="radio" id="see-field_public" name="field_21_visibility" value="public" checked="checked"> Anyone</label></li><li><label for="see-field_loggedin"><input type="radio" id="see-field_loggedin" name="field_21_visibility" value="loggedin"> Logged In Users</label></li><li><label for="see-field_adminsonly"><input type="radio" id="see-field_adminsonly" name="field_21_visibility" value="adminsonly"> Admins Only</label></li><li><label for="see-field_friends"><input type="radio" id="see-field_friends" name="field_21_visibility" value="friends"> My Friends</label></li></ul>
</fieldset>
<a class="field-visibility-settings-close" href="#">Close</a>
</div>
<p class="description"></p>
</div>
I could see how this could be targeted. Are you inspecting on the edit profile page that has the checkbox’s?
Hi @bp-help yes I have, there is no id coming through on the checkboxes, they are coming out without any html wrapped around them, eg:
<div id="profileProjectSize">
£0-£100k, £100k-£500k, £500k-£2m, £2m+
</div>
I can’t see how to give each one an ID
Thanks
@applegateian
Have you tried using firefox in conjunction with firebug to target those elements? You could also use google chromes or IE’s dev tools.
Hi @henrywright-1
The site is behind a password, anywhere I can DM you?
I just can’t see how to add a unique id to each checkbox.
Thanks,
Ian