Filter uncanny-automator

automator_capability

Filters the capability required to manage Automator settings and features.

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

Description

Filters the WordPress capability required for sensitive administrative operations within Uncanny Automator. Developers can change the default 'manage_options' capability to restrict access to recipe building and REST endpoints, enhancing security and fine-grained control over who can manage Automator features. This hook fires when the capability is checked.


Usage

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

Return Value

The filtered value.


Examples

<?php
/**
 * Example: Change the required capability for Uncanny Automator admin operations to 'administrator'
 *
 * This is useful if you want to restrict access to Uncanny Automator's
 * administrative features to users with the 'administrator' role,
 * rather than the default 'manage_options'.
 */
add_filter( 'automator_capability', 'my_custom_automator_capability', 10, 1 );

function my_custom_automator_capability( $capability ) {
    // Check if the current user has the 'manage_options' capability.
    // This prevents accidentally removing access for users who might already have it
    // but aren't administrators if we were to just force 'administrator'.
    if ( current_user_can( 'manage_options' ) ) {
        // If they can manage options, we can safely change the required capability.
        return 'administrator';
    }

    // If the user doesn't have 'manage_options', return the original capability
    // to ensure consistency or fallback behavior.
    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:1410
uncanny-automator-pro/src/global-functions.php:104

function automator_get_capability() {
	return apply_filters( 'automator_capability', 'manage_options' );
}


Scroll to Top