Encoding Contact Data with a Shortcode and Hook for Third-Party Plugins

This article explains how to use the CleanTalk shortcode and hook features to encode and protect contact data. This is especially useful for web developers and site owners who want to hide sensitive information (such as emails or other contact details) from bots while allowing legitimate users to access the information when needed.

Even if the main encoding option is turned off, CleanTalk offers alternative encoding methods via shortcodes and hooks:

1. Using the Shortcode
Add the following code directly into your content using the visual editor:

[apbct_encode_data]any text to encode[/apbct_encode_data]

This will encode the specified text so it appears hidden to bots on the public site. Legitimate users can decode the information by clicking on it, similar to encoded email links.

2. Using the Hook
For developers, the hook apbct_encode_data provides a flexible way to encode any data from source code. Wrap any text you want to encode with this hook, like so:

function encode_contact_data_example () {
    $encoded_text = apply_filters('apbct_encode_data', 'any text to encode');

    echo $encoded_text;
}
add_action( 'wp_footer', 'encode_contact_data_example');

The $encoded_text variable will contain the encoded version of "any text to encode". Display this variable on the page, and it will be accessible to users by click, while remaining hidden from bots.

You can see the result here:

Result

By using these methods, you can control which information is visible to bots and ensure legitimate users can access encoded contact data safely.

Was this information helpful?

It would also be interesting

Copied to clipboard