WordPress.org

Ready to get started?Download WordPress

Forums

Slick Contact Forms
[resolved] Contacting post author? (5 posts)

  1. MarceFX
    Member
    Posted 2 years ago #

    Hi,

    I've set up the contact form to show only on post pages. I want the contact form to send the message to the post author. So far, I know the variable $emailTo retrieves the email where the message will be sent to.

    So I tried:

    $emailTo = get_the_author_meta('user_email');

    But it is not working. I guess it's because the function is outside the WordPress loop. So, the proper code would be:

    $emailTo = get_the_author_meta('user_email', $author_id);

    But I don't know how to get the user ID.

    Any ideas?

    Thank you

    http://wordpress.org/extend/plugins/slick-contact-forms/

  2. remix4
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    Try checking on the WordPress Codex:

    http://codex.wordpress.org/

  3. remix4
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    Try checking on the WordPress Codex:

    http://codex.wordpress.org/

  4. MarceFX
    Member
    Posted 2 years ago #

    I have read all documentation related to the "out of the loop" thing. I googled almost everything I couldn't think of and tried different approaches:

    1.

    $author_id=$post->post_author;

    2.

    global $post;
    $author_id=$post->post_author;

    3.

    $post_tmp = get_post($post_id);
    $author_id = $post_tmp->post_author;

    4.

    $author_id = $posts[0]->post_author;

    But none is working. So, I thought that the plugin may have some custom coding/function altering this :-/

    Thanks

  5. Daedalon
    Member
    Posted 2 years ago #

    Did you try these for debugging:

    global $post;
    print_r( $post );

    to see what the $post contains (maybe you need to use a different field instead of $post->post_author to get the ID), and

    echo $post_id;

    to see if $post_id is set (get_post() doesn't work without a proper ID argument).

    The key for finding the solution you're looking for is to get a visual of what data you have or don't have in order to see what exactly is missing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic