Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Show / Hide XProfile groups based on select value.

By: a guest on Jan 27th, 2012  |  syntax: PHP  |  size: 1.63 KB  |  hits: 169  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php  $roles = array(2 => 'player', 4 => 'coach', 5 =>'parent', 6 => 'instructor'); ?>  
  2. <div id="roles">        
  3. <?php foreach($roles as $key => $role) : ?>                        
  4. <div id="<?php echo $role; ?>" class="role-fields">            
  5.         <?php if(bp_has_profile('profile_group_id='.$key)) : while(bp_profile_groups()) : bp_the_profile_group(); ?>
  6.                 <?php while(bp_profile_fields()) : bp_the_profile_field(); ?>
  7.                         <div class="editfield">
  8.                                 <?php if('textarea' == bp_get_the_profile_field_type()) : ?>
  9.                                         <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>
  10.                                         <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
  11.                                         <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>
  12.                                 <?php endif; ?>        
  13.                         <?php do_action( 'bp_custom_profile_edit_fields' ) ?>
  14.                         <p class="description"><?php bp_the_profile_field_description() ?></p>
  15.                     </div>
  16.                 <?php endwhile; ?>
  17.                 <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
  18.         <?php endwhile; endif; ?>
  19. </div>
  20. <?php endforeach; ?>
  21. </div>
  22.  
  23. <script>
  24. jQuery(".role-fields").hide();
  25. $roles = jQuery("#roles");
  26. jQuery("#field_2").change(function()
  27. {
  28.         $role = jQuery(this).val().toLowerCase();
  29.         jQuery(".role-fields").hide();
  30.         jQuery("#" + $role).toggle();  
  31. });            
  32. </script>