Custom group creation steps (and the “Are you sure you want to do this?” screen)
-
Hi all,
I am working in a site with WP4.5.1 + BP 2.5.2 + bbpress 2.5.8
I have been working on a custom group creation process and I got some good stuff I just want to share with the community. I have noticed that the group creation steps are stored within the $bp object and that they can be accessed and reseted. The standard group creation steps are the following (though they may be reordered in your installation or have less or more steps):
1. Group Details 2. Group Settings 3. Forum 4. Group Avatar 5. Group Image Cover 6. Invite friends
In my case, I needed to get rid of some of those steps and, as well, “Group Image Cover” step was prompting me to the “Are you sure you want to do this?” screen (I think it is related to the nonces, but I am not sure about this).
You can list your particular group creation steps by copying this snippet somewhere in your site (they will be listed in a page – I used my /group/create.php template). I took a part of the code from the function “groups_action_sort_creation_steps”, located in /buddypress/bp-groups/bp-groups-actions.php:
<?php global $bp;
foreach ( (array) $bp->groups->group_creation_steps as $slug => $step ) {
while ( !empty( $temp[$step['position']] ) )
$step['position']++;
$temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
};
print_r(array_values($temp)); ?>
Once you have your steps and you have decided which you want to get rid of, build the array to be passed to the $bp object following this model and the information you found in the previous list:
$temp = array(
"0" => array("name" => "Details","slug" =>"group-details" ),
'1' => array("name" => "Information","slug" =>"plus-tab"),
'2' => array("name" => "Forum","slug" =>"forum" ),
);
And then place this action hook in your bp-custom.php (which is also inspired in the sorting function):
function custom_group_creation_steps() {
global $bp;
unset($bp->groups->group_creation_steps);$temp = array(
"0" => array("name" => "Details","slug" =>"group-details" ),
'1' => array("name" => "Information","slug" =>"plus-tab"),
'2' => array("name" => "Forum","slug" =>"forum" ),
);foreach( (array) $temp as $position => $step )
$bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
}add_action( 'bp_init', 'custom_group_creation_steps' );
As I got rid of the “Image Cover Step”, now my group creation process does not print the annoying “are you sure you want to do this?” screen. But this screen is related to particular setups, so I cannot guarantee you’ll get rid of it with this code.
Happy coding!
- You must be logged in to reply to this topic.