uo_bulk_downlad_cert_capability
Filters the capability required to perform bulk certificate downloads.
add_filter( 'uo_bulk_downlad_cert_capability', $callback, 10, 1 );
Description
This filter allows developers to modify the user capability required to download certificates in bulk. It fires during plugin initialization. Developers can change the required capability from the default 'manage_options' to any other valid WordPress capability, controlling which user roles can access this feature.
Usage
add_filter( 'uo_bulk_downlad_cert_capability', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example of using the 'uo_bulk_downlad_cert_capability' filter to change
* the required capability for bulk certificate downloads.
*
* This example restricts the bulk download functionality to users who have
* the 'edit_posts' capability, which is typically assigned to Authors and above.
*
* @param string $capability The default capability required.
* @return string The modified capability.
*/
add_filter( 'uo_bulk_downlad_cert_capability', function( $capability ) {
// Check if the user has the 'edit_posts' capability.
// If not, we can potentially modify the capability.
// In a real-world scenario, you might also check the current user's role
// or other conditions before returning a different capability.
if ( ! current_user_can( 'edit_posts' ) ) {
// Return 'edit_posts' as the new required capability.
return 'edit_posts';
}
// If the user already has 'manage_options' or we don't need to change it,
// return the original capability.
return $capability;
}, 10, 1 );
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:58
public function __construct() {
add_action( 'plugins_loaded', array( __CLASS__, 'run_frontend_hooks' ) );
self::$capability = apply_filters( 'uo_bulk_downlad_cert_capability', 'manage_options' );
}