[1]

kapsol
Subscriber
May 18th, 2009 at 3:57 am

Hello,

I was wondering if TDOMF can be hacked to address the following needs. Any help is greatly appreciated. Tight deadline. There might also be a reward :-)

The Need:
————–
I need to setup a job application form that collects the usual information from the applicant:
– Name, Address, Phone, Gender, Education, CV (upload), Cover Letter (Upload), Two More Upload Fields
– Three fields for names and e-mail addresses of references

Tricky Part One
- Can I set up a separate form for the references to come to and upload their references to the respective candidates post?

Tricky Part Two
- How do I set the form to e-mail the addresses in the “references” fields with the URL of the “RECOMMENDATION FORM” when the candidate submits his form?

Illustration:
—————-

John Doe fills in application Form1 at Link1. Form1 contains a 3 fields called Reference1 (email), Reference 2 (email), Reference 3 (email).

When John Doe completes the form and submits, an e-mail is sent to all three references with a Link2 to Form2 (which contains file upload fields).

The files uploaded via Form2 are submitted to John Doe\’s original post.

Thanks,

Kapsol

Permalink | Quote

[2]

Mark Cunningham
Administrator
June 8th, 2009 at 12:28 pm

For a start, the second part, references uploading to the posted resume, is not possible yet as I haven’t ported the Upload Files widget over to the Editing Forms (I’m not sure I will, I’d rather create a new widget tbh).

For the first part, it’s doable, but it might be best to do this as a plugin that uses TDOMF, than try and paste this into the form hacker.

==

I haven’t tested this yet (will try it after lunch). Create a new file in you’re wp-content/plugins and called it something like my_auto_email.php. Then paste this into it:

<?php
/*
Plugin Name: My Auto Email
Plugin URI: http://thedeadone.net/forum/?p=3195
Description: Blah
Version: 1
Author: Mark Cunningham
Author URI: http://thedeadone.net
*/

function tdomf_my_auto_email_send($post_id) {
    global $wpdb;

    // tests

    if(wp_is_post_revision($post_id)) {
       // revision - do nothing
       return $post_id;
    }

    if(get_post_meta($post_id, TDOMF_KEY_FLAG, true) == false) {
       // not a TDOMF post - do nothing
       return $post_id;
    }

     if(get_post_meta($post_id,TDOMF_KEY_SPAM,true)) {
      // post is flagged as spam - do nothing.
      return $post_id;
   }

    // grab emails (assumes you're custom fields are called email1, email2 and email3

    $email_list = '';
    $email = get_post_meta($post_id,'email1',true);
    if($email != false) {
       $email_list = trim($email);
    }
    $email = get_post_meta($post_id,'email2',true);
    if($email != false) {
       if(!empty($email_list)) { $email_list .= ','; }
       $email_list .= trim($email);
    }
    $email = get_post_meta($post_id,'email3',true);
    if($email != false) {
       if(!empty($email_list)) { $email_list .= ','; }
       $email_list .= trim($email);
    }

    if(!empty($email_list)) {

            // customise subject and body how you like
            //
            $subject = "Subject of Email";
            $body = "Message of Email. Format how you like!";

            // prepare body
            //
            $body = str_replace("\n","\r\n",$body);

            // You change the "from" field by modifying the headers, which are
            // an option argument to the send email
            //
            $headers = "MIME-Version: 1.0\n" .
  	           "From: blah@blah.com\n" .
  	           "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";

            // Finally, send it!
            @wp_mail($email_list, $subject, $body, $headers);
    }
    return $post_id;
}
add_action('publish_post', 'tdomf_my_auto_email_send');

?>

You should be able to activate this as an plugin and it'll automatically send an email to the three emails stored in Custom Fields named "email1", "email2" and "email3" when a post is published. As long as if the post is not spam and was submitted by TDOMF.

Permalink | Quote

[3]

Mark Cunningham
Administrator
June 8th, 2009 at 1:52 pm

I tested the code – should work.

Permalink | Quote

Advertisments

Join the Discussion