Advertisement
Guest User

Show / Hide XProfile groups based on select value.

a guest
Jan 27th, 2012
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement