Support

Account

Home Forums General Issues Email obfuscation Reply To: Email obfuscation

  • tl;dr Forum isn’t having any part of displaying the encoded text as anything but output. Save the email address as a variable first and then pass it to antispambot to make all of you obfuscation dreams come true. If you view source on this forum post and search for “foo” you can see it in action.

    Interesting. I’m not sure why but I see a way around it. Perhaps @elliot can explain the discrepancy.

    Note: the_field("test_email") was saved as "[email protected]"
    THIS CODE:
    <h2> The Email: <?php echo antispambot( "[email protected]" ) ?> </h2>
    <h2> The Email: <?php echo antispambot( the_field("test_email") ) ?> </h2>
    OUTPUTS:
    <h2> The Email: test@test.com </h2>
    <h2> The Email: [email protected] </h2>

    THIS CODE: (Save as variable first)
    <h2> The Email: <?php echo antispambot( "[email protected]" ) ?> </h2>
    <?php $email = get_field("test_email"); ?>
    <h2> The Email: <?php echo antispambot( $email ) ?> </h2>

    OUTPUTS: What you (we!) were expecting:
    <h2> The Email: test@test.com </h2>
    EDIT: Can’t get it to display properly in the forum but this email address is obfuscated.
    <h2> The Email: foo@bar.com </h2>

    edited for clarity.