/**
 * Automatically close collection after the last client has approved their selection
 */
function my_picu_maybe_close_collection( $collection_id, $ident ) {
	$all_approved = true;

	$clients = get_post_meta( $collection_id, '_picu_collection_hashes', true );

	foreach( $clients as $ident => $client ) {
		if ( $client['status'] != 'approved' ) {
			$all_approved = false;
		}
	}

	if ( $all_approved ) {
		wp_update_post( [
			'ID' => $collection_id,
			'post_status' => 'approved'
		] );

		if ( function_exists( 'picu_update_collection_history' ) ) {
			picu_update_collection_history( $collection_id, 'approved' );
		}
	}
}

add_action( 'picu_after_approval', 'my_picu_maybe_close_collection', 10, 2 );

Still having issues?

In your WordPress Admin go to picu > Settings > Debug Info and send the contents of this page and your questions to support@picu.io.