Filter uncanny-toolkit-pro

uo_bulk_downlad_cert_allowed_roles

Filters the roles allowed to perform bulk certificate downloads, defaulting to administrator and group leader.

add_filter( 'uo_bulk_downlad_cert_allowed_roles', $callback, 10, 1 );

Description

This filter allows customization of which user roles are permitted to download certificates in bulk. By default, administrators and group leaders can access this feature. Developers can modify the returned array to grant or restrict access to other roles, controlling bulk certificate download permissions.


Usage

add_filter( 'uo_bulk_downlad_cert_allowed_roles', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

add_filter( 'uo_bulk_downlad_cert_allowed_roles', 'my_custom_bulk_cert_download_roles', 10, 1 );

/**
 * Allows custom user roles to download certificates in bulk.
 *
 * By default, only 'administrator' and 'group_leader' roles can download
 * certificates in bulk. This function adds 'editor' and 'custom_manager'
 * roles to the allowed list.
 *
 * @param array $allowed_roles An array of user roles allowed to download.
 * @return array The modified array of allowed user roles.
 */
function my_custom_bulk_cert_download_roles( $allowed_roles ) {
	// Add additional roles that should be allowed to download certificates in bulk.
	$allowed_roles[] = 'editor';
	$allowed_roles[] = 'custom_manager';

	// Optionally, you could remove existing roles if you wanted to restrict access further.
	// For example, to remove 'group_leader':
	// $allowed_roles = array_diff( $allowed_roles, array( 'group_leader' ) );

	return $allowed_roles;
}

Placement

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


Source Code

src/classes/download-certificates-in-bulk.php:1161

</div>

			<?php

		} else {

			// Check if the user can request the certificates
			$allowed_roles = apply_filters( 'uo_bulk_downlad_cert_allowed_roles', array(
				'administrator',
				'group_leader'
			));

			$can_download_modules = false;
			foreach( $allowed_roles as $allowed_role ) {
				$can_download = in_array( $allowed_role, (array) $user->roles, true );


Scroll to Top