Beispiel #1
4
 /**
  * Set the notification email when sending an email.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return string The email to notify.
  */
 public function notification_email($components, $cf7, $three = null)
 {
     $submission = WPCF7_Submission::get_instance();
     $unit_tag = $submission->get_meta('unit_tag');
     if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
         return $components;
     }
     $post_id = (int) $matches[2];
     $object = get_post($post_id);
     // Prevent issues when the form is not submitted via a listing/resume page
     if (!isset($this->forms[$object->post_type])) {
         return $components;
     }
     if (!array_search($cf7->id(), $this->forms[$object->post_type])) {
         return $components;
     }
     // Bail if this is the second mail
     if (isset($three) && 'mail_2' == $three->name()) {
         return $components;
     }
     $recipient = $object->_application ? $object->_application : $object->_candidate_email;
     //if we couldn't find the email by now, get it from the listing owner/author
     if (empty($recipient)) {
         //just get the email of the listing author
         $owner_ID = $object->post_author;
         //retrieve the owner user data to get the email
         $owner_info = get_userdata($owner_ID);
         if (false !== $owner_info) {
             $recipient = $owner_info->user_email;
         }
     }
     $components['recipient'] = $recipient;
     return $components;
 }
/**
  * [nombre_del_formulario] [Esto ocupo para comparar el nombre del formulario para guardar en la tabla correcta]
  * 
  * [nombre_de_la_tabla] [se concatena con el prefijo seleccionado en la instalacion que por defecto es wp_ + nombre de la tabla a guardar]
  *
  *	[$submited['posted_data']['nombre_campo_form']] [Para jalar datos del formulario lo sacamos de un array $submited['posted_data'] seguido del nombre del campo ingresado en el form ['nombre_campo_form']]
  * 
  * [save_form Guarda en base cualquier formulario enviado por contact form 7]
  * @param  [type] $wpcf7 [variable global de wp que se utiliza para guardar datos en esta funcion]
  * @return [type]        [description]
*/
function save_form($wpcf7)
{
    global $wpdb;
    /*
     Note: since version 3.9 Contact Form 7 has removed $wpcf7->posted_data
     and now we use an API to get the posted data.
    */
    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $submited = array();
        $submited['title'] = $wpcf7->title();
        $submited['posted_data'] = $submission->get_posted_data();
    }
    /**
     * Uso de la mayoría de formularios acerca de suscribirse o no
     */
    if ($submited['posted_data']['info'] == 'on') {
        $info = 'Si quiero recibir informacion';
    } else {
        $info = 'No quiero recibir informacion';
    }
    if ($submited['title'] == 'nombre_del_formulario') {
        $wpdb->insert($wpdb->prefix . 'nombre_de_la_tabla', array('nombre' => $submited['posted_data']['your-name'], 'apellido' => $submited['posted_data']['last-name'], 'email' => $submited['posted_data']['email-gana'], 'artista' => $submited['posted_data']['artist-fav'], 'info' => $info, 'fecha' => date('Y-m-d')));
    }
}
Beispiel #3
1
function wpcf7_do_before_send($wpcf7)
{
    $submission = WPCF7_Submission::get_instance();
    $data = $submission->get_posted_data();
    $_SESSION['posted_data'] = $data;
    return true;
}
Beispiel #4
1
 function beforeSendEmail($cf7)
 {
     $submission = WPCF7_Submission::get_instance();
     if ($submission) {
         $data = $submission->get_posted_data();
         $dataArr = array_merge($data, array('created_date' => current_time('mysql')));
         add_post_meta($data['_wpcf7'], 'cf7-adb-data', $dataArr);
     }
 }
Beispiel #5
1
function ip_wpcf7_mail_sent($wpcf7){
		$submission = WPCF7_Submission::get_instance();
			if ( $submission ) {
				$formdata = $submission->get_posted_data();
				$email = $formdata['your-email'];
				$first_name = $formdata['your-first-name'];
				$last_name = $formdata['your-last-name'];
				$tel = $formdata['your-tel'];
				$plan = $formdata['your-plan'];
			}
			$time = $today = date("F j, Y, g:i a");
        // Open Agent:
        $curl = curl_init();
        curl_setopt_array($curl, array(
                CURLOPT_RETURNTRANSFER => 1,
                CURLOPT_URL => 'http://ag.panda8.co/api?action=createAgentPph&creditAgent=1000&credit=100&currency=USD&masterId=DEMVI&numOfUser=1&email='.$email.'&key=BBBAB3NzaC1yc2EAAAABJQAAAIEAhCdDMhGHdaw1uj9MH2xCB4jktwIgm4Al7S8rxvovMJBAuFKkMDd0vW5gpurUAB0PEPkxh6QFoBNazvio7Q03f90tSP9qpJMGwZid9hJEElplW8p43D3DdxXykLays2M8V2viYGLbiXvAbOECzwD4IaviOpylX0PaFznSR4ssXd0Int',
                CURLOPT_USERAGENT => 'PPH186',
                CURLOPT_FOLLOWLOCATION => 1,
        ));
		$resp = curl_exec($curl);
        $variables = json_decode($resp,true);
        $agent = strtoupper($variables['agentId']);
        $password = $variables['password'];
        curl_close($curl); 
        // Send Info to bot
		$text = urlencode("-- Sign up -- \n".$time."\n"."First Name: ".$first_name."\n"."Last Name: ".$last_name."\n"."Email: ".$email."\n"."Tel: ".$tel."\n"."Plan: ".$plan."\nAgent ID: ".$agent);
        $curl = curl_init();
        // Set some options - we are passing in a useragent too here
        curl_setopt_array($curl, array(
                CURLOPT_RETURNTRANSFER => 1,
                CURLOPT_URL => 'http://pph186.com/bot.php?key=b6fbc59dea1f5c41551f895886edbee5&msg='.$text.'&agent_id=sa',
                CURLOPT_USERAGENT => 'PPH186'
        ));
		// Send the request & save response to $resp
        $resp = curl_exec($curl);
        // Close request to clear up some resources
        curl_close($curl);
        $params = array(
   					"first_name" => $first_name,
 					"last_name" => $last_name,
  					"phone_mobile" => $tel,
  					"email1" => $email,
  					"account_name" => $agent,
  					"account_description" => $plan,
  					"campaign_id" => "c78e72d1-bfaa-b060-be8e-56cb258c33e6",
  					"assigned_user_id" => "1",
		);
 		echo httpPost("http://crm.pph186.com/index.php?entryPoint=WebToLeadCapture",$params);
 		$_SESSION["first_name"] = $first_name;
 		$_SESSION["last_name"] = $last_name;
 		$_SESSION["account_name"] = $agent;

       
}
function action_wpcf7_mail_sent($contact_form)
{
    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $posted_data = $submission->get_posted_data();
        $to = $posted_data['your-email'];
        $subject = 'Thank you for your interest in GVCO';
        $body = 'Thank you for your interest in the future of the Great Valley Community Organization. A member of our Building Connections Campaign Committee will be in touch with you shortly. In the meantime, be sure to follow us on social media for the latest news and updates.';
        wp_mail($to, $subject, $body);
    }
}
Beispiel #7
0
function tcb_mail_sent_function($contact_form)
{
    $title = $contact_form->title;
    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $posted_data = $submission->get_posted_data();
    }
    if ('referralForm' == $title) {
        $current_user = wp_get_current_user();
        for ($i = 1; $i <= 3; $i++) {
            add_filter('wp_mail_content_type', 'set_html_content_type');
            add_filter('wp_mail_from', 'tcb_website_email');
            add_filter('wp_mail_from_name', 'tcb_website_name');
            if (!$posted_data["email_" . $i]) {
                continue;
            }
            ob_start();
            include TCP_TEMPLATE_PATH . "referral_email.php";
            $message = ob_get_contents();
            ob_end_clean();
            wp_mail($posted_data["email_" . $i], 'e-Voucher from ' . $current_user->user_firstname . " " . $current_user->user_lastname, $message);
            remove_filter('wp_mail_content_type', 'set_html_content_type');
            remove_filter('wp_mail_from_name', 'tcb_website_name');
            remove_filter('wp_mail_from', 'tcb_website_email');
        }
    }
}
Beispiel #8
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);
}
Beispiel #9
0
 function beforeSendEmail($cf7)
 {
     $submission = WPCF7_Submission::get_instance();
     if ($submission) {
         $data = $submission->get_posted_data();
         $dataArr = array_merge($data, array('created_date' => current_time('mysql')));
         add_post_meta($data['_wpcf7'], 'cf7-adb-data', $dataArr);
         $unread_messages = get_post_meta($data['_wpcf7'], 'cf7-adb-data-unread', true);
         update_post_meta($data['_wpcf7'], 'cf7-adb-data-unread', intval($unread_messages) + 1);
         //status 1= show notification | 2 = hide notofication
         update_option('cf7-adb-data-show-notif', 1);
     }
 }
function your_wpcf7_mail_sent_function($contact_form)
{
    $title = $contact_form->title;
    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $posted_data = $submission->get_posted_data();
    }
    if ('Send a Gift 2' == $title) {
        $usergiftBudget = $posted_data['giftBudget'];
        setcookie("CustomBudget", $usergiftBudget, strtotime('+10 minutes'), "/");
        // sleep(10);
    }
}
Beispiel #11
0
function create_user_from_registration($cfdata)
{
    if (!isset($cfdata->posted_data) && class_exists('WPCF7_Submission')) {
        // Contact Form 7 version 3.9 removed $cfdata->posted_data and now
        // we have to retrieve it from an API
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $formdata = $submission->get_posted_data();
        }
    } elseif (isset($cfdata->posted_data)) {
        // For pre-3.9 versions of Contact Form 7
        $formdata = $cfdata->posted_data;
    } else {
        // We can't retrieve the form data
        return $cfdata;
    }
    // Check this is the user registration form
    switch ($cfdata->id()) {
        case 268:
            $ruolo = "hw2_client";
            break;
        case 716:
            $ruolo = "hw2_contributor";
            break;
        case 733:
            $ruolo = "hw2_partner";
            break;
        default:
            $ruolo = "subscriber";
            break;
    }
    $password = wp_generate_password(12, false);
    $email = $formdata['Email'];
    $first = $formdata['First'];
    $last = $formdata['Last'];
    // Construct a username from the user's name
    $username = strtolower(str_replace(' ', '', $first));
    if (!email_exists($email)) {
        // Find an unused username
        $username_tocheck = $username;
        $i = 1;
        while (username_exists($username_tocheck)) {
            $username_tocheck = $username . $i++;
        }
        $username = $username_tocheck;
        // Create the user
        $userdata = array('user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'nickname' => $first, 'display_name' => $first, 'first_name' => $first, 'last_name' => $last, 'role' => $ruolo);
        $user_id = wp_insert_user($userdata);
    }
    return $cfdata;
}
Beispiel #12
0
function tcb_custom_mail_components($WPCF7_ContactForm)
{
    $title = $WPCF7_ContactForm->title;
    if ('referralForm' == $title) {
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $posted_data = $submission->get_posted_data();
        }
        $mail = $WPCF7_ContactForm->prop('mail');
        ob_start();
        include TCP_TEMPLATE_PATH . "referral_email_to_admin.php";
        $message = ob_get_contents();
        ob_end_clean();
        $mail['body'] = str_replace('[referral_content]', $message, $mail['body']);
        $WPCF7_ContactForm->set_properties(array('mail' => $mail));
    }
    if ('Warranty form' == $title) {
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $posted_data = $submission->get_posted_data();
        }
        $password = $posted_data["nric_fin"];
        $user_email = $posted_data["email"];
        $mail = $WPCF7_ContactForm->prop('mail_2');
        $user_id = username_exists($user_email);
        if (!$user_id and email_exists($user_email) == false) {
            $userdata = array('user_login' => $user_email, 'user_pass' => $password, 'user_email' => $user_email, 'first_name' => $posted_data["surname"], 'last_name' => $posted_data["given_name"], 'display_name' => $posted_data["given_name"]);
            $user_id = wp_insert_user($userdata);
            //update extra info for customer
            update_user_meta($user_id, 'salutation', $posted_data['title'], get_the_author_meta('salutation', $user_id));
            update_user_meta($user_id, 'nric_fin_user', $posted_data['nric_fin'], get_the_author_meta('nric_fin', $user_id));
            update_user_meta($user_id, 'dob', $posted_data['date_of_birth'], get_the_author_meta('dob', $user_id));
            update_user_meta($user_id, 'address_user', $posted_data['block'] . " " . $posted_data['street_name'], get_the_author_meta('address', $user_id));
            update_user_meta($user_id, 'postal_code', $posted_data['postal_code'], get_the_author_meta('postal_code', $user_id));
            update_user_meta($user_id, 'phone', $posted_data['contact'], get_the_author_meta('phone', $user_id));
            $message = "<div>Username: "******"</div><div>Password: "******"</div>";
            $mail['body'] = str_replace('[user_pass]', $message, $mail['body']);
            $WPCF7_ContactForm->set_properties(array('mail_2' => $mail));
            global $wpdb;
            $sql = "INSERT INTO {$wpdb->wrranty_db_table} (invoiceId, address, contact, date_of_installation, wrranty_date, user_id) ";
            $sql .= " VALUES ('" . $posted_data["invoice_no"] . "', '" . $posted_data['block'] . " " . $posted_data['street_name'] . "' , '" . $posted_data['contact'] . "' , '" . $posted_data["date_of_installation"] . "', '', '" . $user_id . "') ";
            $wpdb->query($sql);
        } else {
            //            $WPCF7_ContactForm->skip_mail = true;
            $mail['body'] = "";
            $WPCF7_ContactForm->set_properties(array('mail_2' => $mail));
        }
    }
}
 public function contact_form_7($cf7)
 {
     $forms = $this->get_forms('rdcf7_integrations');
     foreach ($forms as $form) {
         $form_id = get_post_meta($form->ID, 'form_id', true);
         if ($form_id == $cf7->id()) {
             $submission = WPCF7_Submission::get_instance();
             if ($submission) {
                 $this->form_data = $submission->get_posted_data();
             }
             $this->generate_static_fields($form->ID, 'Plugin Contact Form 7');
             $this->conversion($this->form_data);
         }
     }
 }
function create_user_from_registration($cfdata)
{
    if (!isset($cfdata->posted_data) && class_exists('WPCF7_Submission')) {
        // Contact Form 7 version 3.9 removed $cfdata->posted_data and now
        // we have to retrieve it from an API
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $formdata = $submission->get_posted_data();
        }
    } elseif (isset($cfdata->posted_data)) {
        // For pre-3.9 versions of Contact Form 7
        $formdata = $cfdata->posted_data;
    } else {
        // We can't retrieve the form data
        return $cfdata;
    }
    // Check this is the user registration form
    if ($cfdata->title() == 'Your Registration Form Title') {
        $password = wp_generate_password(12, false);
        $email = $formdata['form-email-field'];
        $name = $formdata['form-name-field'];
        // Construct a username from the user's name
        $username = strtolower(str_replace(' ', '', $name));
        $name_parts = explode(' ', $name);
        if (!email_exists($email)) {
            // Find an unused username
            $username_tocheck = $username;
            $i = 1;
            while (username_exists($username_tocheck)) {
                $username_tocheck = $username . $i++;
            }
            $username = $username_tocheck;
            // Create the user
            $userdata = array('user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'nickname' => reset($name_parts), 'display_name' => $name, 'first_name' => reset($name_parts), 'last_name' => end($name_parts), 'role' => 'subscriber');
            $user_id = wp_insert_user($userdata);
            if (!is_wp_error($user_id)) {
                // Email login details to user
                $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
                $message = "Welcome! Your login details are as follows:" . "\r\n";
                $message .= sprintf(__('Username: %s'), $username) . "\r\n";
                $message .= sprintf(__('Password: %s'), $password) . "\r\n";
                $message .= wp_login_url() . "\r\n";
                wp_mail($email, sprintf(__('[%s] Your username and password'), $blogname), $message);
            }
        }
    }
    return $cfdata;
}
Beispiel #15
0
function insert_question($question_form)
{
    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $posted_data = $submission->get_posted_data();
    }
    if ($posted_data['checktype'] == 'question') {
        $taxonomy = 'department';
        $term = get_term_by('slug', $posted_data['post_name'], $taxonomy);
        $term_id = $term->term_id;
        // Создание пользователя - автора вопроса
        if ($posted_data['your-email']) {
            $user_email = $posted_data['your-email'];
            $user_name = $posted_data['your-name'];
            $user_id = email_exists($user_email);
            if (!$user_id and email_exists($user_email) == false) {
                $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
                $user_id = wp_create_user($user_name, $random_password, $user_email);
            }
        }
        $question = $posted_data['your-question'];
        // Добавление вопроса
        $question_id = wp_insert_post(array('post_content' => '', 'post_type' => 'question', 'post_title' => $user_name, 'post_excerpt' => $question, 'post_author' => $user_id));
        wp_set_object_terms($question_id, $term_id, $taxonomy);
        // Уведомление специалисту
        $doctors = get_posts(array('post_type' => 'doctor', 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $term_id))));
        if ($doctors) {
            if ($posted_data['post_name'] == 'departments') {
                $page_url = get_site_url() . '/departments';
            } else {
                $page_url = get_site_url() . '/departments/' . $posted_data['post_name'];
            }
            $emails = array();
            $subject = 'Вопрос с сайта ' . get_site_url();
            $message = $posted_data['your-name'] . ' оставил(а) вопрос на странице: ' . $page_url;
            $headers = 'From: ' . get_bloginfo() . ' <no-reply@' . $_SERVER['SERVER_NAME'] . '>' . "\r\n";
            foreach ($doctors as $post) {
                setup_postdata($post);
                $author = get_user_by('login', get_the_author());
                $author_email = $author->user_email;
                array_push($emails, $author_email);
            }
            wp_reset_postdata();
            wp_mail($emails, $subject, $message, $headers);
        }
    }
    return $posted_data;
}
Beispiel #16
0
 /**
  * Set the notification email when sending an email.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return string The email to notify.
  */
 public function notification_email($components, $cf7, $three = null)
 {
     $submission = WPCF7_Submission::get_instance();
     $unit_tag = $submission->get_meta('unit_tag');
     if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
         return $components;
     }
     $post_id = (int) $matches[2];
     $object = get_post($post_id);
     if (!array_search($cf7->id, $this->forms[$object->post_type])) {
         return $components;
     }
     $recipient = $object->_application ? $object->_application : $object->_candidate_email;
     $components['recipient'] = $recipient;
     return $components;
 }
 /**
  * @param $cf7 WPCF7_ContactForm
  * @return object
  */
 public function convertData($cf7)
 {
     if (!isset($cf7->posted_data) && class_exists('WPCF7_Submission')) {
         // Contact Form 7 version 3.9 removed $cf7->posted_data and now
         // we have to retrieve it from an API
         $submission = WPCF7_Submission::get_instance();
         if ($submission) {
             $data = array();
             $data['title'] = $cf7->title();
             $data['posted_data'] = $submission->get_posted_data();
             $data['uploaded_files'] = $submission->uploaded_files();
             return (object) $data;
         }
     }
     return $cf7;
 }
function get_form_data($cf7)
{
    $args = array('post_type' => 'rdcf7_integrations', 'posts_per_page' => 100);
    $forms = get_posts($args);
    foreach ($forms as $form) {
        $form_id = get_post_meta($form->ID, 'form_id', true);
        if ($form_id == $cf7->id) {
            $submission = WPCF7_Submission::get_instance();
            if ($submission) {
                $form_data = $submission->get_posted_data();
            }
            $form_data['token_rdstation'] = get_post_meta($form->ID, 'token_rdstation', true);
            $form_data['identificador'] = get_post_meta($form->ID, 'form_identifier', true);
            addLeadConversion($form_data);
        }
    }
}
Beispiel #19
0
 /**
  * @codeCoverageIgnore
  */
 function getFileURL($filename)
 {
     if ($submission = \WPCF7_Submission::get_instance()) {
         $uploaded_files = $submission->uploaded_files();
         foreach ((array) $uploaded_files as $name => $path) {
             $fpi = pathinfo($path);
             if ($filename === $fpi["basename"] && !empty($path)) {
                 if (@is_readable($path)) {
                     $target = str_replace($fpi["filename"], uniqid("", true), $path);
                     $wpd = wp_upload_dir();
                     copy($path, sprintf("%s/%s", $wpd["path"], basename($target)));
                     wp_schedule_single_event(14 * DAY_IN_SECONDS, $this->delete_file_hook, array($target));
                     return sprintf("%s/%s", $wpd["url"], basename($target));
                 }
             }
         }
     }
     return $filename;
 }
/**
 * Redirect the user to the thanks/success page after submitting the form
 *
 * @since 1.0
 */
function affwp_cf7_success_page_redirect($contact_form)
{
    // Success page ID
    $success_page = affwp_cf7_get_success_page_id();
    $submission = WPCF7_Submission::get_instance();
    // get the value of the name field
    $name = $submission->get_posted_data('your-name');
    // get the description
    $description = rawurlencode($contact_form->title());
    // add customer's email address to the description
    $description .= ' - ' . $submission->get_posted_data('your-email');
    // set the reference to be the first name
    $reference = isset($name) ? rawurlencode($name) : '';
    // redirect to success page
    if ($success_page) {
        $wpcf7 = WPCF7_ContactForm::get_current();
        $wpcf7->set_properties(array('additional_settings' => "on_sent_ok: \"location.replace(' " . add_query_arg(array('description' => $description, 'reference' => $reference, 'amount' => affwp_cf7_get_form_amount($contact_form->id())), get_permalink($success_page)) . " ');\""));
    }
}
 /**
  * Subscribe from Contact Form 7 Forms
  */
 public function new_cf7_subscription($contact_form)
 {
     // was sign-up checkbox checked?
     if ($this->was_checkbox_checked($this->type) === false) {
         return false;
     }
     // get the integration options
     $integration_options = get_option('optin-checkbox-init', '');
     // get the contact form 7 submission instance
     $submission = WPCF7_Submission::get_instance();
     // confirm the submission was received
     if ($submission) {
         // get the submission data
         $posted_data = $submission->get_posted_data();
         // store the email -- this needs to be more dynamic (find string with containing string email?)
         $email = isset($posted_data['your-email']) ? $posted_data['your-email'] : '';
         // submit this subscriber
         return $this->subscribe_user_integration($email, $this->type, apply_filters('yikes-mailchimp-contact-form-7', array(), $posted_data));
     }
 }
 /**
  * @param $cf7 WPCF7_ContactForm
  * @return object
  */
 public function convertData($cf7)
 {
     if (!isset($cf7->posted_data) && class_exists('WPCF7_Submission')) {
         // Contact Form 7 version 3.9 removed $cf7->posted_data and now
         // we have to retrieve it from an API
         $submission = WPCF7_Submission::get_instance();
         if ($submission) {
             $data = array();
             $data['title'] = $cf7->title();
             $data['posted_data'] = $submission->get_posted_data();
             $data['uploaded_files'] = $submission->uploaded_files();
             $data['WPCF7_ContactForm'] = $cf7;
             if ('true' == $this->plugin->getOption('IntegrateWithCF7SavePageTitle', 'false', true)) {
                 $data['posted_data']['Page Title'] = wpcf7_special_mail_tag('', '_post_title', '');
             }
             if ('true' == $this->plugin->getOption('IntegrateWithCF7SavePageUrl', 'false', true)) {
                 $data['posted_data']['Page URL'] = wpcf7_special_mail_tag('', '_post_url', '');
             }
             return (object) $data;
         }
     }
     return $cf7;
 }
Beispiel #23
0
function wpcf7_update_email_body($contact_form) {
  $submission = WPCF7_Submission::get_instance();

  if ($submission) {

    $mail = $contact_form->prop('mail');
    $posted_data = $submission->get_posted_data();
    $region_id = $posted_data['regionID'];

    if (!$region_id) {
      return true;
    }

    $recipient = get_post_meta($region_id, "contact_email", true);

    if (!$recipient) {
      return true;
    }

    $mail['recipient'] = $recipient;
    $contact_form->set_properties(array('mail' => $mail));

  }
}
Beispiel #24
0
 /**
  * Set the notification email when sending an email.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return string The email to notify.
  */
 public function notification_email($components, $cf7, $three = null)
 {
     $submission = WPCF7_Submission::get_instance();
     $unit_tag = $submission->get_meta('unit_tag');
     if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
         return $components;
     }
     $post_id = (int) $matches[2];
     $object = get_post($post_id);
     // Prevent issues when the form is not submitted via a listing/resume page
     if (!isset($this->forms[$object->post_type])) {
         return $components;
     }
     if (!array_search($cf7->id(), $this->forms[$object->post_type])) {
         return $components;
     }
     // Bail if this is the second mail
     if (isset($three) && 'mail_2' == $three->name()) {
         return $components;
     }
     $recipient = $object->_application ? $object->_application : $object->_candidate_email;
     $components['recipient'] = $recipient;
     return $components;
 }
Beispiel #25
0
 private function replace_tags_callback($matches, $html = false)
 {
     // allow [[foo]] syntax for escaping a tag
     if ($matches[1] == '[' && $matches[4] == ']') {
         return substr($matches[0], 1, -1);
     }
     $tag = $matches[0];
     $tagname = $matches[2];
     $values = $matches[3];
     if (!empty($values)) {
         preg_match_all('/"[^"]*"|\'[^\']*\'/', $values, $matches);
         $values = wpcf7_strip_quote_deep($matches[0]);
     }
     $do_not_heat = false;
     if (preg_match('/^_raw_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $do_not_heat = true;
     }
     $format = '';
     if (preg_match('/^_format_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $format = $values[0];
     }
     $submission = WPCF7_Submission::get_instance();
     $submitted = $submission ? $submission->get_posted_data($tagname) : null;
     if (null !== $submitted) {
         if ($do_not_heat) {
             $submitted = isset($_POST[$tagname]) ? $_POST[$tagname] : '';
         }
         $replaced = $submitted;
         if (!empty($format)) {
             $replaced = $this->format($replaced, $format);
         }
         $replaced = wpcf7_flat_join($replaced);
         if ($html) {
             $replaced = esc_html($replaced);
             $replaced = wptexturize($replaced);
         }
         $replaced = apply_filters('wpcf7_mail_tag_replaced', $replaced, $submitted, $html);
         $replaced = wp_unslash(trim($replaced));
         $this->replaced_tags[$tag] = $replaced;
         return $replaced;
     }
     $special = apply_filters('wpcf7_special_mail_tags', '', $tagname, $html);
     if (!empty($special)) {
         $this->replaced_tags[$tag] = $special;
         return $special;
     }
     return $tag;
 }
 public function submit($ajax = false)
 {
     $submission = WPCF7_Submission::get_instance($this);
     $result = array('status' => $submission->get_status(), 'message' => $submission->get_response(), 'demo_mode' => $this->in_demo_mode());
     if ($submission->is('validation_failed')) {
         $result['invalid_fields'] = $submission->get_invalid_fields();
     }
     if ($submission->is('mail_sent')) {
         if ($ajax) {
             $on_sent_ok = $this->additional_setting('on_sent_ok', false);
             if (!empty($on_sent_ok)) {
                 $result['scripts_on_sent_ok'] = array_map('wpcf7_strip_quote', $on_sent_ok);
             }
         }
     }
     if ($ajax) {
         $on_submit = $this->additional_setting('on_submit', false);
         if (!empty($on_submit)) {
             $result['scripts_on_submit'] = array_map('wpcf7_strip_quote', $on_submit);
         }
     }
     do_action('wpcf7_submit', $this, $result);
     return $result;
 }
Beispiel #27
0
function ll_akismet_comment_check($comment)
{
    global $akismet_api_host, $akismet_api_port;
    $spam = false;
    $query_string = http_build_query($comment);
    if (is_callable(array('Akismet', 'http_post'))) {
        // Akismet v3.0+
        $response = Akismet::http_post($query_string, 'comment-check');
    } else {
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    }
    if ('true' == $response[1]) {
        $spam = true;
    }
    if ($submission = WPCF7_Submission::get_instance()) {
        $submission->akismet = array('comment' => $comment, 'spam' => $spam);
    }
    return apply_filters('ll_akismet_comment_check', $spam, $comment);
}
Beispiel #28
0
function wpcf7_file_validation_filter($result, $tag)
{
    $tag = new WPCF7_Shortcode($tag);
    $name = $tag->name;
    $id = $tag->get_id_option();
    $file = isset($_FILES[$name]) ? $_FILES[$name] : null;
    if ($file['error'] && UPLOAD_ERR_NO_FILE != $file['error']) {
        $result->invalidate($tag, wpcf7_get_message('upload_failed_php_error'));
        return $result;
    }
    if (empty($file['tmp_name']) && $tag->is_required()) {
        $result->invalidate($tag, wpcf7_get_message('invalid_required'));
        return $result;
    }
    if (!is_uploaded_file($file['tmp_name'])) {
        return $result;
    }
    $allowed_file_types = array();
    if ($file_types_a = $tag->get_option('filetypes')) {
        foreach ($file_types_a as $file_types) {
            $file_types = explode('|', $file_types);
            foreach ($file_types as $file_type) {
                $file_type = trim($file_type, '.');
                $file_type = str_replace(array('.', '+', '*', '?'), array('\\.', '\\+', '\\*', '\\?'), $file_type);
                $allowed_file_types[] = $file_type;
            }
        }
    }
    $allowed_file_types = array_unique($allowed_file_types);
    $file_type_pattern = implode('|', $allowed_file_types);
    $allowed_size = 1048576;
    // default size 1 MB
    if ($file_size_a = $tag->get_option('limit')) {
        $limit_pattern = '/^([1-9][0-9]*)([kKmM]?[bB])?$/';
        foreach ($file_size_a as $file_size) {
            if (preg_match($limit_pattern, $file_size, $matches)) {
                $allowed_size = (int) $matches[1];
                if (!empty($matches[2])) {
                    $kbmb = strtolower($matches[2]);
                    if ('kb' == $kbmb) {
                        $allowed_size *= 1024;
                    } elseif ('mb' == $kbmb) {
                        $allowed_size *= 1024 * 1024;
                    }
                }
                break;
            }
        }
    }
    /* File type validation */
    // Default file-type restriction
    if ('' == $file_type_pattern) {
        $file_type_pattern = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
    }
    $file_type_pattern = trim($file_type_pattern, '|');
    $file_type_pattern = '(' . $file_type_pattern . ')';
    $file_type_pattern = '/\\.' . $file_type_pattern . '$/i';
    if (!preg_match($file_type_pattern, $file['name'])) {
        $result->invalidate($tag, wpcf7_get_message('upload_file_type_invalid'));
        return $result;
    }
    /* File size validation */
    if ($file['size'] > $allowed_size) {
        $result->invalidate($tag, wpcf7_get_message('upload_file_too_large'));
        return $result;
    }
    wpcf7_init_uploads();
    // Confirm upload dir
    $uploads_dir = wpcf7_upload_tmp_dir();
    $uploads_dir = wpcf7_maybe_add_random_dir($uploads_dir);
    $filename = $file['name'];
    $filename = wpcf7_canonicalize($filename);
    $filename = sanitize_file_name($filename);
    $filename = wpcf7_antiscript_file_name($filename);
    $filename = wp_unique_filename($uploads_dir, $filename);
    $new_file = trailingslashit($uploads_dir) . $filename;
    if (false === @move_uploaded_file($file['tmp_name'], $new_file)) {
        $result->invalidate($tag, wpcf7_get_message('upload_failed'));
        return $result;
    }
    // Make sure the uploaded file is only readable for the owner process
    @chmod($new_file, 0400);
    if ($submission = WPCF7_Submission::get_instance()) {
        $submission->add_uploaded_file($name, $new_file);
    }
    return $result;
}
function ldcce_cf7_get_uploaded_files()
{
    $submission = WPCF7_Submission::get_instance();
    return $submission->uploaded_files();
}
/**
 * Adds new event that send notification to Slack channel
 * when someone sent message through Contact Form 7.
 *
 * @param  array $events
 * @return array
 *
 * @filter slack_get_events
 */
function wp_slack_wpcf7_submit($events)
{
    $events['wpcf7_submit'] = array('action' => 'wpcf7_mail_sent', 'description' => __('When someone sent message through Contact Form 7', 'slack'), 'message' => function ($form, $result) {
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $posted_data = $submission->get_posted_data();
        }
        return apply_filters('slack_wpcf7_submit_message', sprintf(__('*%s* just sent a message titled "*%s*" through *%s*. Check your email!', 'slack'), $posted_data['your-name'], $posted_data['your-subject'], $form->title), $form, $result);
    });
    return $events;
}