WordPress.org

Ready to get started?Download WordPress

Forums

PHPEnkoder
[resolved] Using it with get_the_author_meta? (11 posts)

  1. bcwint00
    Member
    Posted 5 months ago #

    Hi there,

    I created a custom author page and also added a field for my writers to input a custom email address to receive emails rather than it being sent to the emails they're registered with via the blog.

    This is my code:

    <?php if(get_the_author_meta('pubemail')){ ?><div id="ap-email">Email: <a href="mailto:<?php the_author_meta('pubemail'); ?>"><?php the_author_meta('pubemail'); ?></a></div><?php } ?>

    The custom variable is 'pubemail' which stores their inputted address via their profile page.

    How exactly do I added eckode variables to enkode it?

    https://wordpress.org/plugins/php-enkoder/

  2. michael_greenberg
    Member
    Plugin Author

    Posted 5 months ago #

    One simple way would be to write:


    <?php if(get_the_author_meta('pubemail')){ ?><div id="ap-email">Email: <?
    $email = the_author_meta('pubemail');
    echo enkode_mailto($email,$email);
    ?></div><?php } ?>

    That <i>should</i> work. If it doesn't, try calling enkode directly with the constructed link.

    As a side note, I don't know about you, but if I got any pubemail, I'd ask for it to be returned to sender. ;)

  3. bcwint00
    Member
    Posted 5 months ago #

    Haha thanks! At the moment we're trying to become fully complaint to qualify for Google News service, and they're asking that we include some form of front facing contact per author. Usually I wouldn't have done that but yea.

  4. michael_greenberg
    Member
    Plugin Author

    Posted 5 months ago #

    I was more commenting on the variable name, but I hear you. :) Did that code fragment work?

  5. bcwint00
    Member
    Posted 5 months ago #

    Ah ok! haha

    Just tried it and it doesn't seem to work.

    I've got this as the raw output.

    <div id="ap-email">Email: johndoes@johndoe.com<script type="text/javascript">the long string of code here</script><a href="mailto:"></a></div>

    The email still showed up and the code didn't seem to encode everything.

  6. michael_greenberg
    Member
    Plugin Author

    Posted 5 months ago #

    Okay, give this a try:


    <?php if(get_the_author_meta('pubemail')){ ?><div id="ap-email">Email: <?
    $email = the_author_meta('pubemail');
    echo enkode("$email");
    ?></div><?php } ?>

  7. michael_greenberg
    Member
    Plugin Author

    Posted 5 months ago #

    Ugh, the forum just converted my link to an actual link---in the encode call up there, you want to encode <a href='mailto:$email'&rt;$email<a&rt;.

  8. michael_greenberg
    Member
    Plugin Author

    Posted 5 months ago #

    GAH, stupid forum software. I think you know what I mean...

  9. bcwint00
    Member
    Posted 5 months ago #

    Yea figured out what you meant. The output is still the same though :(

    I don't know if the fact that it's outside the loop and on the author page will make a difference to the equation?

  10. michael_greenberg
    Member
    Plugin Author

    Posted 5 months ago #

    No, it shouldn't. Could you email me the exact code you're writing in?

  11. bcwint00
    Member
    Posted 5 months ago #

    Sent!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.