Skip to:

Re: Can you run multiple profile loops in single/profile-loop.php ?

Boone Gorges


Hi @pollyplummer. You have basically got the right idea, but there are a few problems.

First, your check for usermeta is not formatted correctly. See for get_usermeta syntax. In any case, get_usermeta gets stuff from the wp_usermeta table, and I used it as an example in my code to give you a sense of the kind of check you’d want to do. But that’ll only work if you’re checking against a piece of data that is stored using update_usermeta. BP xprofile fields are not. If the “114” information is stored in a bp xprofile field, you will probably have to do some magic with xprofile_get_field() to get it to work. The following will check for a field called “Type” and check to see if the current user’s Type value is 114:

$field_id = xprofile_get_field_id_from_name( 'Type' );
$field = xprofile_get_field( $field_id );
$value = $field->data->value;

if ( bp_the_profile_group_name() == 'awesome' && $value == '114' ) {

There’s probably a slicker way to do this, but it works. Again, this is only relevant if you’re storing the salient data in the xprofile tables.

The second problem is that you don’t want to repeat the bp_has_profile etc stuff inside of the if statement. If you want to feed a profile_group_id argument to bp_has_profile, you should do it in the initial loop.

Then make sure that you include the markup inside of the conditional if statement. In edit.php, that means everything, including the

tag, that creates the markup enabling the user to edit that group of profile items.
Skip to toolbar