User Account Monitor

The User Account Monitor plugin has a number of useful hooks for developers to use to further enhance its functionality.

uamonitor_flag_settings

TYPE ⇢ Filter

Allows adding or modifying the plugin’s flag-related settings options. This filter receives the current array of flag setting definitions and expects a modified array returned. You must add a callback with the below uamonitor_custom_flag_callback hook to perform the flag check.

Parameters:

  • $options (array): The current array of flag setting definitions.

Example Usage

PHP
/**
 * Add a custom flag setting to detect usernames with repeated characters.
 *
 * @param array $options The current array of flag setting definitions.
 *
 * @return array Modified array including the new flag setting.
 */
add_filter( 'uamonitor_flag_settings', function( $options ) {
    $options[] = [
        'key'        => 'repeated_characters',
        'title'      => __( 'Repeated Characters', 'user-account-monitor' ),
        'comments'   => __( 'Flags if the names contain 4 or more identical consecutive characters.', 'user-account-monitor' ),
        'field_type' => 'checkbox',
        'sanitize'   => 'sanitize_checkbox',
        'section'    => 'checks',
        'default'    => true,
    ];
    return $options;
} );

uamonitor_custom_flag_callback

TYPE ⇢ Filter

Allows defining custom callback functions to perform additional flag checks. The callback should accept a user object and the flag key, returning true if the flag condition is met. You must add a setting with the above uamonitor_flag_settings hook and enable it for the following to work.

Parameters:

  • $callback (callable|null): The current callback or null if none set.
  • $key (string): The flag key being checked.

Example Usage

PHP
/**
 * Provide a custom callback for a specific flag key.
 *
 * @param callable|null $callback The current callback or null if none set.
 * @param string        $key      The flag key being checked.
 *
 * @return callable|null A callable that accepts ($user, $key) and returns boolean.
 */
add_filter( 'uamonitor_custom_flag_callback', function( $callback, $key ) {
    if ( $key === 'repeated_characters' ) {
        return function( $user, $key ) {
            $first = strtolower( $user->first_name ?? '' );
            $last  = strtolower( $user->last_name ?? '' );

            return preg_match( '/(.)\1{3,}/', $first ) || preg_match( '/(.)\1{3,}/', $last );
        };
    }
    return $callback;
}, 10, 2 );

uamonitor_names_to_scan

TYPE ⇢ Filter

Allows customization of the user name fields scanned for suspicious patterns. By default, it scans the first_name, last_name, and display_name fields.

Parameters:

  • $names_to_scan (array): The current array of name fields to scan.

Example Usage

PHP
/**
 * Customize the name fields to scan for suspicious patterns.
 *
 * @param array $names_to_scan The current array of name fields to scan.
 *
 * @return array Modified array of name fields.
 */
add_filter( 'uamonitor_names_to_scan', function( $names_to_scan ) {
    // Add 'nickname' to the fields being scanned
    $names_to_scan[] = 'nickname';
    return $names_to_scan;
} );

uamonitor_consonant_cluster_pattern

TYPE ⇢ Filter

Allows customization of the regex pattern used to detect consonant clusters in user names. The default pattern matches six or more consecutive consonants.

Parameters:

  • $pattern (string): The current regex pattern used for detection.
  • $field (string): The name field being checked (e.g., 'first_name', 'last_name', 'display_name').
  • $user_or_name (object|string): The user object or name string being scanned.

Example Usage

PHP
/**
 * Modify the consonant cluster pattern to detect 5 or more consecutive consonants.
 *
 * @param string        $pattern       The existing regex pattern.
 * @param string        $field         The name field being checked.
 * @param object|string $user_or_name  The user object or name string.
 *
 * @return string Modified regex pattern.
 */
add_filter( 'uamonitor_consonant_cluster_pattern', function( $pattern, $field, $user_or_name ) {
    return '/[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]{5,}/';
}, 10, 3 );

uamonitor_special_characters_name_pattern

TYPE ⇢ Filter

Allows customizing the regex pattern used to detect special characters in user name fields (excluding email addresses). The default pattern matches any character that is not a Unicode letter, comma, period, apostrophe, hyphen, or whitespace.

Parameters:

  • $pattern (string): The current regex pattern used for detection.
  • $name (string): The name being checked.
  • $field (string): The name field being checked (e.g., 'first_name', 'last_name', 'display_name').
  • $user_or_name (object|string): The user object or name string being scanned.

Example Usage

PHP
/**
 * Modify the pattern for detecting special characters in names.
 *
 * @param string        $pattern      The existing regex pattern.
 * @param string        $name         The name being checked.
 * @param string        $field        The name field.
 * @param object|string $user_or_name The user object or name string.
 *
 * @return string Modified regex pattern.
 */
add_filter( 'uamonitor_special_characters_name_pattern', function( $pattern, $name, $field, $user_or_name ) {
    // Example: disallow apostrophes as special characters
    return '/[^\p{L}\,\.\-\s]/u';
}, 10, 4 );

uamonitor_special_characters_email_pattern

TYPE ⇢ Filter

Allows customizing the regex pattern used to detect special characters in email addresses within the display name field. The default pattern matches any character that is not alphanumeric, @, period, hyphen, underscore, or plus sign.

Parameters:

  • $pattern (string): The current regex pattern used for detection.
  • $name (string): The name being checked.
  • $field (string): The name field being checked (e.g., 'first_name', 'last_name', 'display_name').
  • $user_or_name (object|string): The user object or name string being scanned.

Example Usage

PHP
/**
 * Modify the pattern for detecting special characters in names.
 *
 * @param string        $pattern      The existing regex pattern.
 * @param string        $name         The name being checked.
 * @param string        $field        The name field.
 * @param object|string $user_or_name The user object or name string.
 *
 * @return string Modified regex pattern.
 */
add_filter( 'uamonitor_special_characters_name_pattern', function( $pattern, $name, $field, $user_or_name ) {
    // Example: restrict allowed characters to alphanumeric, '@', '.', and '-'
    return '/[^a-zA-Z0-9@\.\-]/';
}, 10, 4 );

uamonitor_short_name_length

TYPE ⇢ Filter

Filters the character length threshold used to flag short names. This allows developers to customize what qualifies as a "short" name for flagging purposes.

Parameters:

  • $args (array): Array of short name rule parameters.
    • 'allow_single' (bool): Whether 1-character names are allowed. Default true.
    • 'allow_two' (bool): Whether 2-character names are allowed. Default false.
    • 'cap' (int): The maximum length to consider for short name flagging. Default 2.

Example Usage

PHP
/**
 * Customize the rules for short name detection.
 *
 * @param array $args {
 *     Array of rule arguments.
 *
 *     @type bool $allow_single Whether to allow 1-character names. Default true.
 *     @type bool $allow_two    Whether to allow 2-character names. Default false.
 *     @type int  $cap          Max length to be considered "short". Default 2.
 * }
 *
 * @return array Modified rule arguments.
 */
add_filter( 'uamonitor_short_name_length', function( $args ) {
    return [
        'allow_single' => false,
        'allow_two'    => true,
        'cap'          => 3,
    ];
} );

uamonitor_allow_email_domains

TYPE ⇢ Filter

Allows specifying an allowlist of email domains that should never be flagged as invalid, overriding other checks.

Parameters:

  • $allow_domains (array): Current array of allowed email domains.

Example Usage

PHP
/**
 * Add custom domains to the allowlist to bypass invalid domain flagging.
 *
 * @param array $allow_domains Current allowlist of email domains.
 *
 * @return array Modified allowlist including custom domains.
 */
add_filter( 'uamonitor_allow_email_domains', function( $allow_domains ) {
    $allow_domains[] = 'example.com';
    $allow_domains[] = 'mycompany.org';
    return $allow_domains;
} );

uamonitor_disposable_domains

TYPE ⇢ Filter

Allows customizing the list of disposable email domains that are flagged as invalid.

Parameters:

  • $disposable_domains (array): Current array of disposable email domains.

Example Usage

PHP
/**
 * Add custom domains to the disposable email domain list.
 *
 * @param array $disposable_domains Current list of disposable domains.
 *
 * @return array Modified list including additional disposable domains.
 */
add_filter( 'uamonitor_disposable_domains', function( $disposable_domains ) {
    $disposable_domains[] = 'tempmail.net';
    $disposable_domains[] = 'fakeinbox.com';
    return $disposable_domains;
} );

uamonitor_default_spam_words

TYPE ⇢ Filter

Allows customization of the default list of spam trigger words used to detect suspicious user bios and names.

Parameters:

  • $default_spam_words (array): The current array of default spam words.

Example Usage

PHP
/**
 * Add custom spam trigger words to the default list.
 *
 * @param array $default_spam_words Current array of default spam words.
 *
 * @return array Modified array including additional spam words.
 */
add_filter( 'uamonitor_default_spam_words', function( $default_spam_words ) {
    $default_spam_words[] = 'cheap pills';
    $default_spam_words[] = 'work from home job';
    return $default_spam_words;
} );

uamonitor_spam_words_found

TYPE ⇢ Action

Triggered after spam words are detected in a user’s bio or name fields. Provides the user ID and an array of matched spam words.

Parameters:

  • $user_id (int): The ID of the user flagged.
  • $found_words (array): Array of spam words matched in the user’s data.

Example Usage

PHP
/**
 * Log detected spam words when a user is flagged.
 *
 * @param int   $user_id     The flagged user ID.
 * @param array $found_words The spam words detected.
 */
add_action( 'uamonitor_spam_words_found', function( $user_id, $found_words ) {
    error_log( sprintf( 'User %d flagged for spam words: %s', $user_id, implode( ', ', $found_words ) ) );
}, 10, 2 );

Words Already Added

  • Generic Marketing:
    buy now, click here, limited time, special offer, order now, shop now, free trial, get started, try now, subscribe now, instant access, act now, save big, don’t miss out, sign up, join now
  • Financial:
    cash, money back, 100% free, guaranteed, no risk, risk-free, winner, earn, income, double your, investment, profit, easy money, work from home, be your own boss
  • Urgency:
    urgent, immediately, limited supply, only a few left, while supplies last, today only, last chance, final notice
  • Prizes and Incentives:
    bonus, prize, free gift, reward, giveaway, claim now, congratulations, you’ve been selected, exclusive deal, you’re a winner
  • Health / Medications:
    weight loss, miracle, cure, anti-aging, treatment, pain relief, no prescription, pharmacy, viagra, levitra, cialis
  • Scam / Phishing Indicators:
    act now, dear friend, confidential, no obligation, click below, password, bank account, credit card, ssn, login, verify your account, update your information
  • Adult / Spam Content:
    xxx, sex, nude, adult, porn, escort, camgirl, hot girls, dating, hookup, live chat, strip
  • Shortened Domains (omit if checking separately):
    bit.ly, tinyurl, goo.gl, t.co
  • Cryptocurrency / High-Risk Finance:
    bitcoin, crypto, blockchain, forex, binary options, nft, token sale
  • SEO / Web Services:
    seo, backlinks, traffic, page rank, optimize your site, site audit, web design, email list, mailing list, marketing campaign
  • Bot-Like Language:
    great post, thanks for sharing, check out my site, visit my blog, contact me, looking for friends, nice article, helpful info, i love this, interesting content, amazing write-up, follow me
  • Foreign Marketing Phrases:
    acheter maintenant, meilleur prix, angebot, jetzt kaufen, compra ahora, precio bajo

uamonitor_check_after_flagged

TYPE ⇢ Action

Fires after a user has been flagged as suspicious.

Parameters:

  • $user (WP_User): The flagged user object.
  • $user_flags (array): Array of flag keys that were triggered.

Example Usage

PHP
/**
 * Fires after a user is flagged as suspicious.
 *
 * @param WP_User $user       The flagged user object.
 * @param array   $user_flags Array of flag keys that were triggered.
 */
add_action( 'uamonitor_check_after_flagged', function( $user, $user_flags ) {
    // Handle flagged user logic.
}, 10, 2 );

uamonitor_check_after_cleared

TYPE ⇢ Action

Fires after a user is checked and no flags are triggered.

Parameters:

  • $user (WP_User): The flagged user object.
  • $user_flags (array): Array of flag keys that were triggered.

Example Usage

PHP
/**
 * Fires after a user is checked and no flags are triggered.
 *
 * @param WP_User $user       The cleared user object.
 * @param array   $user_flags An empty array.
 */
add_action( 'uamonitor_check_after_cleared', function( $user, $user_flags ) {
    // Handle cleared user logic.
}, 10, 2 );

uamonitor_integrations_fields

TYPE ⇢ Filter

Allows external plugins to add integration-specific settings fields to the User Account Monitor options array. For a full integration example, we recommend checking out the Gravity Forms integration on GitHub.

Parameters:

  • $fields (array): The current array of settings fields.

Example Usage

PHP
/**
 * Add a custom setting field for integration.
 *
 * @param array $fields The existing settings fields.
 * @return array Modified fields.
 */
add_filter( 'uamonitor_integrations_fields', function( $fields ) {
    $fields[] = [
        'key'        => 'my_plugin_setting',
        'title'      => __( 'My Plugin Setting', 'my-text-domain' ),
        'comments'   => __( 'Enable integration with My Plugin.', 'my-text-domain' ),
        'field_type' => 'checkbox',
        'sanitize'   => 'sanitize_checkbox',
        'section'    => 'integrations',
        'default'    => false,
    ];
    return $fields;
} );

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.