Filter uncanny-automator-pro

automator_pro_generate_random_string_upper_alphabets

Filters the uppercase alphabet string used for generating random strings.

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

Description

Filters the default set of uppercase alphabets ('ABCDEFGHIJKLMNOPQRSTUVWXYZ') used in generating random strings within Uncanny Automator Pro. Developers can modify this string to include or exclude specific uppercase characters.


Usage

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

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to modify the allowed uppercase alphabets for the Uncanny Automator Pro
 * 'automator_pro_generate_random_string_upper_alphabets' filter.
 *
 * This example will remove the letters 'A', 'B', and 'C' from the default uppercase alphabet
 * when Uncanny Automator Pro generates a random string using uppercase letters.
 */
add_filter(
	'automator_pro_generate_random_string_upper_alphabets',
	function ( $default_uppercase_alphabets ) {
		// Remove specific characters from the default string.
		$modified_uppercase_alphabets = str_replace( array( 'A', 'B', 'C' ), '', $default_uppercase_alphabets );

		// Return the modified string of allowed characters.
		return $modified_uppercase_alphabets;
	},
	10, // Priority: standard priority
	1   // Accepted args: the filter receives one argument ($default_uppercase_alphabets)
);

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

uncanny-automator-pro/src/integrations/generator/actions/uoa-generate-random-string.php:206

public function generate_random_string( $length = 16, $nums = 'false', $lower_abc = 'false', $upper_abc = 'false', $special_chars = 'false' ) {
		if (
			'false' === $nums &&
			'false' === $lower_abc &&
			'false' === $upper_abc &&
			'false' === $special_chars
		) {
			$nums          = 'true';
			$lower_abc     = 'true';
			$upper_abc     = 'true';
			$special_chars = 'true';
		}

		$allowed_chars = '';

		if ( 'false' !== $nums ) {
			$allowed_chars .= apply_filters( 'automator_pro_generate_random_string_numbers', '0123456789' );
		}

		if ( 'false' !== $lower_abc ) {
			$allowed_chars .= apply_filters( 'automator_pro_generate_random_string_lower_alphabets', 'abcdefghijklmnopqrstuvwxyz' );
		}

		if ( 'false' !== $upper_abc ) {
			$allowed_chars .= apply_filters( 'automator_pro_generate_random_string_upper_alphabets', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' );
		}

		if ( 'false' !== $special_chars ) {
			$allowed_chars .= apply_filters( 'automator_pro_generate_random_string_special_chars', '!#$%&()*+,-./:;<=>?@[]^_`{|}~' );
		}

		$allowed_chars = apply_filters( 'automator_pro_generate_random_string_allowed_characters', $allowed_chars );

		return substr( str_shuffle( str_repeat( $allowed_chars, ceil( $length / strlen( $allowed_chars ) ) ) ), 1, $length );
	}


Scroll to Top