
Show / Hide XProfile groups based on select value.
By: a guest on
Jan 27th, 2012 | syntax:
PHP | size: 1.63 KB | hits: 114 | expires: Never
<?php $roles = array(2 => 'player', 4 => 'coach', 5 =>'parent', 6 => 'instructor'); ?>
<div id="roles">
<?php foreach($roles as $key => $role) : ?>
<div id="<?php echo $role; ?>" class="role-fields">
<?php if(bp_has_profile('profile_group_id='.$key)) : while(bp_profile_groups()) : bp_the_profile_group(); ?>
<?php while(bp_profile_fields()) : bp_the_profile_field(); ?>
<div class="editfield">
<?php if('textarea' == bp_get_the_profile_field_type()) : ?>
<label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
<?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
<textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea>
<?php endif; ?>
<?php do_action( 'bp_custom_profile_edit_fields' ) ?>
<p class="description"><?php bp_the_profile_field_description() ?></p>
</div>
<?php endwhile; ?>
<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
<?php endwhile; endif; ?>
</div>
<?php endforeach; ?>
</div>
<script>
jQuery(".role-fields").hide();
$roles = jQuery("#roles");
jQuery("#field_2").change(function()
{
$role = jQuery(this).val().toLowerCase();
jQuery(".role-fields").hide();
jQuery("#" + $role).toggle();
});
</script>