Example #1
0
function wpcf7_flamingo_before_send_mail($contactform)
{
    if (!(class_exists('Flamingo_Contact') && class_exists('Flamingo_Inbound_Message'))) {
        return;
    }
    if (empty($contactform->posted_data) || !empty($contactform->skip_mail)) {
        return;
    }
    $fields_senseless = $contactform->form_scan_shortcode(array('type' => array('captchar', 'quiz', 'acceptance')));
    $exclude_names = array();
    foreach ($fields_senseless as $tag) {
        $exclude_names[] = $tag['name'];
    }
    $posted_data = $contactform->posted_data;
    foreach ($posted_data as $key => $value) {
        if ('_' == substr($key, 0, 1) || in_array($key, $exclude_names)) {
            unset($posted_data[$key]);
        }
    }
    $email = isset($posted_data['your-email']) ? trim($posted_data['your-email']) : '';
    $name = isset($posted_data['your-name']) ? trim($posted_data['your-name']) : '';
    $subject = isset($posted_data['your-subject']) ? trim($posted_data['your-subject']) : '';
    $meta = array();
    $special_mail_tags = array('remote_ip', 'user_agent', 'url', 'date', 'time', 'post_id', 'post_name', 'post_title', 'post_url', 'post_author', 'post_author_email');
    foreach ($special_mail_tags as $smt) {
        $meta[$smt] = apply_filters('wpcf7_special_mail_tags', '', '_' . $smt, false);
    }
    if (isset($contactform->akismet)) {
        $akismet = (array) $contactform->akismet;
    }
    Flamingo_Contact::add(array('email' => $email, 'name' => $name));
    Flamingo_Inbound_Message::add(array('channel' => 'contact-form-7', 'subject' => $subject, 'from' => trim(sprintf('%s <%s>', $name, $email)), 'from_name' => $name, 'from_email' => $email, 'fields' => $posted_data, 'meta' => $meta, 'akismet' => $akismet));
}
Example #2
0
function wpcf7_flamingo_before_send_mail($contactform)
{
    if (!(class_exists('Flamingo_Contact') && class_exists('Flamingo_Inbound_Message'))) {
        return;
    }
    if (empty($contactform->posted_data) || !empty($contactform->skip_mail)) {
        return;
    }
    $fields_senseless = $contactform->form_scan_shortcode(array('type' => array('captchar', 'quiz', 'acceptance')));
    $exclude_names = array();
    foreach ($fields_senseless as $tag) {
        $exclude_names[] = $tag['name'];
    }
    $posted_data = $contactform->posted_data;
    foreach ($posted_data as $key => $value) {
        if ('_' == substr($key, 0, 1) || in_array($key, $exclude_names)) {
            unset($posted_data[$key]);
        }
    }
    $meta = array('remote_ip' => apply_filters('wpcf7_special_mail_tags', '', '_remote_ip'), 'url' => apply_filters('wpcf7_special_mail_tags', '', '_url'), 'date' => apply_filters('wpcf7_special_mail_tags', '', '_date'), 'time' => apply_filters('wpcf7_special_mail_tags', '', '_time'), 'post_id' => apply_filters('wpcf7_special_mail_tags', '', '_post_id'), 'post_name' => apply_filters('wpcf7_special_mail_tags', '', '_post_name'), 'post_title' => apply_filters('wpcf7_special_mail_tags', '', '_post_title'), 'post_url' => apply_filters('wpcf7_special_mail_tags', '', '_post_url'), 'post_author' => apply_filters('wpcf7_special_mail_tags', '', '_post_author'), 'post_author_email' => apply_filters('wpcf7_special_mail_tags', '', '_post_author_email'));
    $args = array('channel' => 'contact-form-7', 'fields' => $posted_data, 'meta' => $meta, 'email' => '', 'name' => '', 'from' => '', 'subject' => '');
    if (!empty($posted_data['your-email'])) {
        $args['from_email'] = $args['email'] = trim($posted_data['your-email']);
    }
    if (!empty($posted_data['your-name'])) {
        $args['from_name'] = $args['name'] = trim($posted_data['your-name']);
    }
    if (!empty($posted_data['your-subject'])) {
        $args['subject'] = trim($posted_data['your-subject']);
    }
    $args['from'] = trim(sprintf('%s <%s>', $args['from_name'], $args['from_email']));
    Flamingo_Contact::add($args);
    Flamingo_Inbound_Message::add($args);
}
Example #3
0
function wpcf7_flamingo_submit($contactform, $result)
{
    if (!class_exists('Flamingo_Contact') || !class_exists('Flamingo_Inbound_Message')) {
        return;
    }
    if ($contactform->in_demo_mode() || $contactform->is_true('do_not_store')) {
        return;
    }
    $cases = (array) apply_filters('wpcf7_flamingo_submit_if', array('spam', 'mail_sent', 'mail_failed'));
    if (empty($result['status']) || !in_array($result['status'], $cases)) {
        return;
    }
    $submission = WPCF7_Submission::get_instance();
    if (!$submission || !($posted_data = $submission->get_posted_data())) {
        return;
    }
    $fields_senseless = $contactform->form_scan_shortcode(array('type' => array('captchar', 'quiz', 'acceptance')));
    $exclude_names = array();
    foreach ($fields_senseless as $tag) {
        $exclude_names[] = $tag['name'];
    }
    $exclude_names[] = 'g-recaptcha-response';
    foreach ($posted_data as $key => $value) {
        if ('_' == substr($key, 0, 1) || in_array($key, $exclude_names)) {
            unset($posted_data[$key]);
        }
    }
    $email = wpcf7_flamingo_get_value('email', $contactform);
    $name = wpcf7_flamingo_get_value('name', $contactform);
    $subject = wpcf7_flamingo_get_value('subject', $contactform);
    $meta = array();
    $special_mail_tags = array('remote_ip', 'user_agent', 'url', 'date', 'time', 'post_id', 'post_name', 'post_title', 'post_url', 'post_author', 'post_author_email');
    foreach ($special_mail_tags as $smt) {
        $meta[$smt] = apply_filters('wpcf7_special_mail_tags', '', '_' . $smt, false);
    }
    $akismet = isset($submission->akismet) ? (array) $submission->akismet : null;
    if ('mail_sent' == $result['status']) {
        Flamingo_Contact::add(array('email' => $email, 'name' => $name));
    }
    $channel_id = wpcf7_flamingo_add_channel($contactform->name(), $contactform->title());
    if ($channel_id) {
        $channel = get_term($channel_id, Flamingo_Inbound_Message::channel_taxonomy);
        if (!$channel || is_wp_error($channel)) {
            $channel = 'contact-form-7';
        } else {
            $channel = $channel->slug;
        }
    } else {
        $channel = 'contact-form-7';
    }
    $args = array('channel' => $channel, 'subject' => $subject, 'from' => trim(sprintf('%s <%s>', $name, $email)), 'from_name' => $name, 'from_email' => $email, 'fields' => $posted_data, 'meta' => $meta, 'akismet' => $akismet, 'spam' => 'spam' == $result['status']);
    Flamingo_Inbound_Message::add($args);
}
Example #4
0
function flamingo_collect_contacts_from_comments()
{
    $comments = get_comments(array('status' => 'approve', 'type' => 'comment', 'number' => 20));
    foreach ($comments as $comment) {
        $email = $comment->comment_author_email;
        $name = $comment->comment_author;
        if (empty($email)) {
            continue;
        }
        Flamingo_Contact::add(array('email' => $email, 'name' => $name, 'channel' => 'comment'));
    }
}
Example #5
0
function flamingo_collect_contacts_from_users()
{
    $users = get_users(array('number' => 20));
    foreach ($users as $user) {
        $email = $user->user_email;
        $name = $user->display_name;
        if (empty($email)) {
            continue;
        }
        $props = array('first_name' => empty($user->first_name) ? '' : $user->first_name, 'last_name' => empty($user->last_name) ? '' : $user->last_name);
        Flamingo_Contact::add(array('email' => $email, 'name' => $name, 'props' => $props, 'channel' => 'user'));
    }
}