Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to create more fields in a group? (5 posts)

Started 1 year, 3 months ago by: ericooliveira

  • Profile picture of ericooliveira ericooliveira said 1 year, 3 months ago:

    I would like to know if there a plugin or other way to create more fields for users fill when he are creating a group. Thanks.

  • Profile picture of crazywhistlepig crazywhistlepig said 1 year, 2 months ago:

    As would I. I am using a buddypress installation to manage organizations as groups, and need to add the org’s address, and other info. Is this possible?

    Thanks!

  • Profile picture of r-a-y r-a-y said 1 year, 2 months ago:

    No plugin exists for this at the moment.

    This has to be manually coded. If you’re a plugin developer, check out this codex article:

    http://codex.buddypress.org/developer-docs/group-extension-api/

    And also check out the groupmeta functions in /bp-groups.php.

    There are a few threads about this on buddypress.org. I’d suggest doing a search on Google.

    An example can be found here:

    http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/profile-fields-for-groups#post-78706

  • Profile picture of 4ella 4ella said 1 year ago:

    I would like to know that too , it is strange that nobody didn’t create it till now , because many times the groups are companies , and those have addresses so it should be nice to have all location info of any group on some group “map- location-contact” page .

  • Profile picture of nit3watch nit3watch said 1 year ago:

    I put this together some time ago though should still work. change gcode and dress code to what you would like. Save it as what ever you would like, with a php extension and place it in your plugins. Active and gl :P I also greated some group map plugin some time ago thats floating around on the forums.. you would have to search or wait for gpress.

    <?php
    /*
    Plugin Name: BuddyPress Group Dress Code
    Plugin URI:
    Description: This plugin adds an additional field to group creation for a dress code
    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:
    */
    
    /* Show group dresscode number in group header */
    $gdcode_show_dresscode_in_header = true ;
    
    /* - HERE BEGINS THE CODE - */
    
    // create the form to add the field
    function gdcode_add_dresscode_form() {
    	?>
    	<label for="group-dresscode"><?php _e( 'Dress code', 'gdcode' ) ?></label>
    	<input type="text" name="group-dresscode" id="group-dresscode" value="<?php echo gdcode_get_group_dresscode() ;?>" />
    
    	<?php 
    
    }
    add_action( 'groups_custom_group_fields_editable', 'gdcode_add_dresscode_form' );
    
    // Save the dresscode number in the group meta - perhaps use serialize() and maybe_unserialize()
    function gdcode_save_dresscode( $group_id ) {
    	global $bp;
    
    	if($bp->groups->new_group_id)
    		$id = $bp->groups->new_group_id;
    	else
    		$id = $group_id;
    
    	if ( $_POST['group-dresscode']  )
    		groups_update_groupmeta( $id, 'gdcode_group_dresscode', $_POST['group-dresscode'] );
    }
    
    // Get or return the dresscode number
    function gdcode_group_dresscode() {
    	echo gdcode_get_group_dresscode();
    }
    	function gdcode_get_group_dresscode( $group = false ) {
    		global $groups_template;
    		if ( !$group )
    			$group =& $groups_template->group;
    		$group_dresscode = groups_get_groupmeta( $group->id, 'gdcode_group_dresscode' );
    		$group_dresscode = stripcslashes( $group_dresscode );
    		return apply_filters( 'gdcode_get_group_dresscode', $group_dresscode );
    	}
    
    // show dresscode number in group header
    function gdcode_show_dresscode_in_header( $description ) {
    	global $gdcode_show_dresscode_in_header;
    	if ( gdcode_get_group_dresscode() && $gdcode_show_dresscode_in_header ) {
    		$description .= '<div class="gdcode-header">'. __('Dress code', 'gdcode').':  </div>'.gdcode_make_dresscode_for_group().'';
    	}
    	return $description;
    }
    add_filter( 'bp_get_group_description', 'gdcode_show_dresscode_in_header' );
    
    // show number for an individual group
    function gdcode_make_dresscode_for_group() {
    	global $bp, $wpdb, $gdcode_args;	
    
    	$group_dresscode = gdcode_get_group_dresscode();
    	$group_dresscode = ' <div class="gdcode-header-col">'.$group_dresscode.'</div> ';
    
    	return $group_dresscode;
    }
    
    add_action( 'groups_create_group_step_save_group-details', 'gdcode_save_dresscode' );
    add_action( 'groups_details_updated', 'gdcode_save_dresscode' );
    ?>