Advertisement
Guest User

Untitled

a guest
Jun 28th, 2010
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 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. ?>
  20. <label for="group-field"><?php _e( 'Location', 'gfield' ) ?></label>
  21. <input type="text" name="group-field" id="group-field" value="" />
  22.  
  23. <?php
  24.  
  25. }
  26. add_action( 'groups_custom_group_fields_editable', 'gfield_add_field_form' );
  27.  
  28. // Save the field value/s in the group meta - perhaps use serialize() and maybe_unserialize()
  29. function gfield_save_field( $group_id ) {
  30. global $bp;
  31.  
  32. if($bp->groups->new_group_id)
  33. $id = $bp->groups->new_group_id;
  34. else
  35. $id = $group_id;
  36.  
  37. if ( $_POST['group-field'] )
  38. groups_update_groupmeta( $id, 'gfield_group_field', $_POST['group-field'] );
  39. }
  40. add_action( 'groups_create_group_step_save_group-details', 'gfield_save_field' );
  41. add_action( 'groups_details_updated', 'gfield_save_field' );
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement