Re: Custom Page that Filters Groups
function bp_featured_group_form() {
if ( is_site_admin ) {
?>
<hr />
<div class="radio">
<label><input type="radio" name="bp_featured_group" value="normal" <?php bp_featured_group_setting('normal') ?> /> <?php _e( 'This is just a normal group', 'featured_group' ) ?></label>
<label><input type="radio" name="bp_featured_group" value="Featured" <?php bp_featured_group_setting('Featured') ?> /> <?php _e( 'This is a featured group', 'featured_group' ) ?></label>
</div>
<hr />
<?php
}
}
add_action ( 'bp_after_group_settings_admin' ,'bp_featured_group_form' );
add_action ( 'bp_after_group_settings_creation_step' ,'bp_featured_group_form' );
function bp_featured_group() {
if (bp_get_featured_group()) {
echo bp_get_featured_group();
}
}
// Get the official title group setting
function bp_get_featured_group( $group = false ) {
global $groups_template;
if ( !$group )
$group =& $groups_template->group;
$featured_group = groups_get_groupmeta( $group->id, 'bp_featured_group' );
return apply_filters( 'bp_featured_group', $featured_group );
}
// echo official title group checked setting for the group admin - default to 'normal' in group creation
function bp_featured_group_setting( $setting ) {
if ( $setting == bp_get_featured_group() )
echo ' checked="checked"';
if ( !bp_get_featured_group() && $setting == 'normal' )
echo ' checked="checked"';
}
// Save the official_title group setting in the group meta, if normal, delete it
function bp_save_featured_group( $group_id ) {
global $bp, $_POST;
if ( $postval = $_POST['bp_featured_group'] ) {
if ( $postval == 'Featured' )
groups_update_groupmeta( $group_id->id, 'bp_featured_group', $postval );
elseif ( $postval='normal' )
groups_delete_groupmeta( $group_id->id, 'bp_featured_group' );
}
}
add_action( 'groups_group_after_save', 'bp_save_featured_group' );
I may as well post the code,
Here it is.
Thanks