Advertisement
Guest User

Untitled

a guest
Jun 28th, 2010
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: BuddyPress GField
  4. Plugin URI:
  5. Description: This plugin adds an additional field to group creation
  6. Version: 1.0
  7. Revision Date: June 25, 2010
  8. License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
  9. Author: Charl Kruger
  10. Author URI:
  11. */
  12.  
  13.  
  14. /* - HERE BEGINS THE CODE - */
  15.  
  16.  
  17. // create the form to add the field
  18. function gfield_add_field_form() {
  19. global $show_group_add_form;
  20. if ($show_group_add_form)
  21. return;
  22. $show_group_add_form = true;
  23. ?>
  24. <label for="group-field"><?php _e( 'Location', 'gfield' ) ?></label>
  25. <input type="text" name="group-field" id="group-field" value="" />
  26.  
  27. <?php
  28.  
  29. }
  30. add_action( 'bp_after_group_details_creation_step', 'gfield_add_field_form' );
  31. add_action( 'groups_custom_group_fields_editable', 'gfield_add_field_form' );
  32.  
  33. // Save the field value/s in the group meta - perhaps use serialize() and maybe_unserialize()
  34. function gfield_save_field( $group_id ) {
  35. global $bp;
  36.  
  37. if($bp->groups->new_group_id)
  38. $id = $bp->groups->new_group_id;
  39. else
  40. $id = $group_id;
  41.  
  42. if ( $_POST['group-field'] )
  43. groups_update_groupmeta( $id, 'gfield_group_field', $_POST['group-field'] );
  44. }
  45. add_action( 'groups_create_group_step_save_group-details', 'gfield_save_field' );
  46. add_action( 'groups_details_updated', 'gfield_save_field' );
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement