Obfuscate email wordpress

Obfuscating an email address in WordPress can be done in a few ways to prevent spam bots from scraping and sending unsolicited emails. Here are a few methods:

Method 1: Using the contact-form-7 plugin

If you're using the contact-form-7 plugin, you can use the [email*] shortcode to obfuscate the email address. For example:

<p>Send an email to <a href="mailto:[email*]">[email*]</a></p>

This will render the email address as a link, but the email address itself will be obfuscated.

Method 2: Using the wp_mail function

You can use the wp_mail function to send an email and obfuscate the email address. For example:

<?php
$email = '[email protected]';
$obfuscated_email = str_replace('@', '[at]', str_replace('.', '[dot]', $email));
echo '<a href="mailto:'. $obfuscated_email. '">'. $obfuscated_email. '</a>';
?>

This will render the email address as a link, but the email address itself will be obfuscated.

Method 3: Using a third-party plugin

There are several third-party plugins available that can help you obfuscate email addresses in WordPress. Some popular options include:

Method 4: Using a custom function

You can also create a custom function to obfuscate email addresses in your WordPress theme or plugin. For example:

function obfuscate_email($email) {
    return str_replace('@', '[at]', str_replace('.', '[dot]', $email));
}

You can then use this function to obfuscate email addresses throughout your website.

Remember to always test your obfuscation method to ensure it's working correctly and not breaking any functionality on your website.