Filter uncanny-automator

automator_admin_capability

Filters the capability required for administrators to access automator features, allowing for custom permission levels.

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

Description

This filter allows developers to customize the WordPress capability required to access Uncanny Automator's administrative areas. By default, it's set to 'manage_options'. Use this hook early in the WordPress loading process to modify the required capability, granting or restricting access to specific user roles for plugin administration.


Usage

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

Return Value

The filtered value.


Examples

<?php

/**
 * Conditionally change the admin capability required for Uncanny Automator admin pages.
 *
 * This example demonstrates how to restrict access to Uncanny Automator's
 * admin pages to users with the 'edit_others_posts' capability, instead of the
 * default 'manage_options'. This might be useful for allowing content editors
 * to manage automations without giving them full administrative control.
 */
add_filter( 'automator_admin_capability', 'my_custom_automator_admin_capability', 10, 1 );

function my_custom_automator_admin_capability( $capability ) {
    // Check if the current user has the 'edit_others_posts' capability.
    // If they do, we'll allow them access to Automator's admin pages.
    // Otherwise, they will be restricted by the default capability.
    if ( current_user_can( 'edit_others_posts' ) ) {
        return 'edit_others_posts';
    }

    // If the user doesn't have the desired capability, return the original capability.
    return $capability;
}
?>

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/global-functions.php:1431
uncanny-automator-pro/src/global-functions.php:126

function automator_get_admin_capability() {
	return apply_filters( 'automator_admin_capability', 'manage_options' );
}


Scroll to Top