Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: BuddyPress GField
- Plugin URI:
- Description: This plugin adds an additional field to group creation
- Version: 1.0
- Revision Date: June 25, 2010
- License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
- Author: Charl Kruger
- Author URI:
- */
- /* - HERE BEGINS THE CODE - */
- // create the form to add the field
- function gfield_add_field_form() {
- global $show_group_add_form;
- if ($show_group_add_form)
- return;
- $show_group_add_form = true;
- ?>
- <label for="group-field"><?php _e( 'Location', 'gfield' ) ?></label>
- <input type="text" name="group-field" id="group-field" value="" />
- <?php
- }
- add_action( 'bp_after_group_details_creation_step', 'gfield_add_field_form' );
- add_action( 'groups_custom_group_fields_editable', 'gfield_add_field_form' );
- // Save the field value/s in the group meta - perhaps use serialize() and maybe_unserialize()
- function gfield_save_field( $group_id ) {
- global $bp;
- if($bp->groups->new_group_id)
- $id = $bp->groups->new_group_id;
- else
- $id = $group_id;
- if ( $_POST['group-field'] )
- groups_update_groupmeta( $id, 'gfield_group_field', $_POST['group-field'] );
- }
- add_action( 'groups_create_group_step_save_group-details', 'gfield_save_field' );
- add_action( 'groups_details_updated', 'gfield_save_field' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement