WordPress.org

Ready to get started?Download WordPress

Forums

Email Address Encoder
[resolved] Encoding e-mails from custom fields (11 posts)

  1. Miood
    Member
    Posted 2 years ago #

    Hi,
    I use "Advanced Custom Fields" plugin to show email addresses on posts but "Simple Mail Address Encoder" seems to not work with that adresses. Is it possible to make it works?

    http://wordpress.org/extend/plugins/email-address-encoder/

  2. Till Krüss
    Member
    Plugin Author

    Posted 2 years ago #

    Sure, just read the FAQ section: "How can I filter other parts of my site?"

  3. Miood
    Member
    Posted 2 years ago #

    Thank you for reply, but can you tell me precisely what should I do? I'm not a coder and this is why i just need more complex solution, than the right direction :)

    The code in single.php:
    <p><a href="mailto: <?php the_field('mail'); ?>"target="_blank"><?php the_field('mail'); ?></a></p>

    How to use eae_encode_emails function to filter this?
    Thanks for help.

  4. Till Krüss
    Member
    Plugin Author

    Posted 2 years ago #

    That should do it:

    <p><a href="<?php echo eae_encode_str('mailto:'.get_field('mail')); ?>"><?php echo eae_encode_str(get_field('mail')); ?></a></p>

  5. Miood
    Member
    Posted 2 years ago #

    Thank you, works great!

  6. captainbr
    Member
    Posted 1 year ago #

    I also have Advanced Custom Fields installed.

    In Simple.php I replaced
    <a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a> <br />
    with
    <p><a href="<?php echo eae_encode_str('mailto:'.get_field('mail')); ?>"><?php echo eae_encode_str(get_field('mail')); ?></a></p>
    and it is not encoding the address.

    The page is http://sidneybcdirectory.com/hagens-computers/

  7. Till Krüss
    Member
    Plugin Author

    Posted 1 year ago #

    Your code seems to use your own $email variable, try this:

    <a href="<?php echo eae_encode_str( 'mailto:' . $email ); ?>"><?php echo eae_encode_str( $email ); ?></a>

  8. captainbr
    Member
    Posted 1 year ago #

    Thanks for the quick response. I inserted your code and I can still see plain text when I view the source.

    Here is my code<p><a href="<?php echo eae_encode_str( 'mailto:' . $email ); ?>"><?php echo eae_encode_str( $email ); ?></a></p> <br />

    Should the extra spaces be present?

    Thanks for your help.

  9. Till Krüss
    Member
    Plugin Author

    Posted 1 year ago #

    The extra spaces are just easier to read.

    If you call the function eae_encode_str() you output will be encoded for sure. Maybe you site is cached?

    You cannot use Firebug, Web Inspector or Dragonfly, to test the encoding, because they decode decimal/hexadecimal entities into plain text. To make sure your email address is encoded, right-click/secondary-click the page, click "View Source", "View Page Source" or "Source" and search for any plain text email addresses.

  10. captainbr
    Member
    Posted 1 year ago #

    Hi Till, I am not using any caching as far as I know. I have refreshed the page and also used F5.

    I have looked on my site on another computer which has never viewed the site. I am using View Page Source and the plain text is still visible.

  11. Till Krüss
    Member
    Plugin Author

    Posted 1 year ago #

    Well, then the only reason I can come up with is that you're editing the wrong file, because everything that gets passed through eae_encode_str() will be encoded. Sure you're editing the right file?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic