Skip to:
Content
Pages
Categories
Search
Top
Bottom

Temporary Groups


  • plumis
    Participant

    @plumis

    Hello guys! i want to make all groups to be temporary and be deleted after 15 minutes or if there are no users in it. Any help?

Viewing 1 replies (of 1 total)
  • Hi @plumis-

    A group will always have an admin (the person who created it), so I’m not sure about your criteria for deletion, but deleting groups is straightforward. You’re going to need to add some cron jobs that run every fifteen minutes, then find the groups your want to delete (based on your criteria). Something like this:

    
    // Get recently created groups:
    $groups = groups_get_groups();
    
    foreach ($groups as $group) {
    	// Delete groups with only one member.
    	$members = groups_get_group_members( array( 'exclude_admins_mods' ) );
    	if ( 1 == $members['count'] ) {
    		groups_delete_group( $group->id );
    	}
    }
    

    You’ll have to figure some things out, like how to schedule run the routine via cronjob (check out this plugin https://wordpress.org/plugins/wp-crontrol/), and also what your criteria will be. bp-groups-functions.php has many helpful functions in it that you could use.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar