Advertisement
Guest User

Untitled

a guest
Jun 27th, 2010
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 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 ) {
  35. if ( $_POST['group-field'] ) {
  36. groups_update_groupmeta( $group->id, 'gfield_group_field', $_POST['group-field'] );
  37. } else {
  38. groups_delete_groupmeta( $group->id, 'gfield_group_field' );
  39. }
  40. }
  41. add_action( 'groups_group_after_save', 'gfield_save_field' );
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement