WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: SimpleModal Contact Form (SMCF)] Adding the page title to the subject line of email (4 posts)

  1. pnelsen
    Member
    Posted 4 years ago #

    Eric, love the plug-in and it's simplicity. What is the best way to auto add the page title to the subject line and not mess with the form...ie "Subject: Call Me -- mydomain.com/new-product/" where 'Call Me' is their input and the other is the page they clicked on the form from.

    http://wordpress.org/extend/plugins/simplemodal-contact-form-smcf/

  2. Eric Martin
    Member
    Posted 4 years ago #

    Hello,

    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&pagetitle=' + encodeURIComponent(document.title),

    Then in smcf_data.php, below:

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

    Add:

    if (isset($_POST["pagetitle"])) {
       $message .= "\n\nPage Title: " . isset($_POST["pagetitle"]);
    }

    I haven't tested it, so let me know if you have any issue.

    -Eric

  3. Mike
    Member
    Posted 3 years ago #

    I'm interested in this, too. I'd prefer to have the page title included in the body of the email rather than the subject, but either way will work. I tried the above, but it didn't work. Any other suggestions?

  4. Thorned Rose
    Member
    Posted 3 years ago #

    @pnelsen I did this by altering smcf.php by changing line (about) 209 to this:

    if (get_option("smcf_form_subject") == 1) {
    			$output .= "
    				    <input type='hidden' id='smcf-subject' class='smcf-input' name='subject' value='". single_post_title('Enquiry about ', false) . "' readonly='readonly' tabindex='1003' />";

    You will probably need to change the "single_post_title" to whatever type of page you have as single_post_title is specific to (funnily enough) the title of a single post page (the_title may work, but I don't remember as that can only be used within the loop).

    @Mike You can do the same thing above - just add value='". single_post_title('Enquiry about ', false) . "' to the <textarea id='smcf-message'> on line (about) 215 (bearing in mind that you will also need to change single_post_title to whatever type of page it is.

Topic Closed

This topic has been closed to new replies.

About this Topic