gravityflowfolders_folders

Added in version 1.4

The gravityflowfolders_folders filter allows customization of the list of folders can be added/removed from. If customizing this filter you may want to look at gravityflowfolders_folder_match_remove_step and gravityflowfolders_folder_match_add_step

Parameters

Parameter Type Definition
$folder_configs Array The configuration for each defined folder.

Examples

Example 1 - Define folders based on a WordPress taxonomy.

add_filter( 'gravityflowfolders_folders', 'folders_execgroups', 10,  1 );
function folders_execgroups( $folder_configs ) {

	// Retrieve the set of objects you want to base additional folders on.
	$execgroups = get_terms( array(
		'taxonomy' => 'execgroup',
		'hide_empty' => false,
	) );

	if( ! empty( $execgroups ) ) {
		//Loop through the array - in this example case it is a custom taxonomy
		foreach( $execgroups as $execgroup ) {
			// JS generates a random id for direct folder creation.
			// Use the term data as seed to generate an approximate random id of same length/
			$folder_configs[] = array(
				'id'          => substr( md5($execgroup->term_id), 0, 9),
				'name'        => $execgroup->name,
				'permissions' => 'all',
				'assignees'   => array(),
			);
		}
	}

	return $folder_configs;
}

Placement

This code should be placed in the functions.php file of your active theme or in a custom functions plugin.