This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

BP-Group-Submit-Form

By: dassoubarna on Apr 9th, 2013  |  syntax: PHP  |  size: 1.30 KB  |  views: 61  |  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
  2. global $bp, $wpdb;
  3. ?>
  4. <?php do_action( 'bp_before_groups_loop' ); ?>
  5. <?php if ( bp_has_groups( 'type=alphabetical&per_page=99999' ) ) : ?>
  6. <?php do_action( 'bp_before_directory_groups_list' ); ?>
  7. <?php while ( bp_groups() ) : bp_the_group();
  8. if ((bp_get_group_id() != 212) && (bp_get_group_id() != 213)) :
  9. ?>
  10. <form action="<?php bp_departments_join(); ?>" method="post" id="department-request-form" class="standard-form">
  11. <input type="checkbox" id="<?php bp_group_id(); ?>" name="select_departments[]" value="<?php bp_group_id(); ?>" /><?php bp_group_name(); ?>&nbsp;
  12. <?php endif; ?>
  13. <?php endwhile; ?>
  14. <div class="group-button">
  15. <input type="submit" name="department-request-submit" id="request_membership" value="Request Membership" />
  16. </div>
  17. </form>
  18. <?php do_action( 'bp_after_directory_groups_list' ); ?>
  19. <?php else: ?>
  20. <div id="message" class="info">
  21. <p><?php _e( 'There were no groups found.', 'buddypress' ); ?></p>
  22. </div>
  23. <?php endif; ?>
  24. <?php do_action( 'bp_after_groups_loop' ); ?>
  25. <?php
  26. function bp_departments_join( $user_id ) {
  27. global $bp, $wpdb;
  28. $selected_departments['select_departments'];
  29. foreach ($selected_departments as $group_id) {
  30. $bp->groups->current_group = groups_get_group(array('group_id' => $group_id));
  31. groups_join_group($group_id, $user_id);
  32. }
  33. return $user_id;
  34. }
  35. ?>
clone this paste RAW Paste Data