WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] SimpleModal Contact Form question (4 posts)

  1. scormeny
    Member
    Posted 4 years ago #

    I like the SMCF plugin and would like to ask if there's a way to include the URL of the web page (or title of the WP page/post) on which the form was accessed, in the body of the email that is delivered. I'm using this on a site where I am hoping to ask people to contact my client with specific questions about the post that they're looking at, so that would be REALLY useful!

    Thank you.

  2. scormeny
    Member
    Posted 4 years ago #

    Sorry to be a pest about this -- when I originally posted three days ago, there were some strange issues that prevented me from tagging this topic or elaborating with a reply. Now I can do that, so please consider this a (hopefully better-worded) "bump".

    I would like to include the permalink of the page that the person filled out the SMCF form on, to the content that comes in the body of the email message.

    Is it possible to call the permalink in the plugin, and then add it to the body of the email message? I feel like it should be easy to do, but not for a php n00b like me.

    Thanks.

  3. scormeny
    Member
    Posted 4 years ago #

    Eric Martin and I corresponded directly with each other. Here's what he sent me, which did what I wanted:

    In js/smcf.js, change:

    data: $('#smcf-container form').serialize() + '&action=send',

    To:

    data: $('#smcf-container form').serialize() +
    '&action=send&permalink=' + encodeURIComponent(location.href),

    Then in smcf_data.php, below:

    if (get_option("smcf_ua")) {
    	$message .= "\n\nUSER AGENT: " . $_SERVER["HTTP_USER_AGENT"];
    }

    Add:

    $permalink = isset($_POST["permalink"]) ? $_POST["permalink"] : "";
    if ($permalink) {
    	$message .= "\n\nPERMALINK: " . $permalink;
    }

    Make sure to clear your browser cache if it's not working for you right away, or get a friend to test it from another computer.

    Thank you, Eric!

  4. Eric Martin
    Member
    Posted 4 years ago #

    This question was resolved via email. Here was the proposed solution:

    There are a number of ways to accomplish your request, but try
    this out and see if it fits your needs:

    In js/smcf.js, change:

    data: $('#smcf-container form').serialize() + '&action=send',

    To:

    data: $('#smcf-container form').serialize() +
    '&action=send&permalink=' + encodeURIComponent(location.href),

    Then in smcf_data.php, below:

    if (get_option("smcf_ua")) {
           $message .= "\n\nUSER AGENT: " . $_SERVER["HTTP_USER_AGENT"];
    }

    Add:

    if (isset($_POST["permalink"])) {
       $message .= "\n\nPERMALINK: " . isset($_POST["permalink"]);
    }

Topic Closed

This topic has been closed to new replies.

About this Topic