function cp_contact_ad_owner_email2($post_id, $files) { $errors = new WP_Error(); // check for required post data $expected = array('from_name', 'from_email', 'subject', 'message'); foreach ($expected as $field_name) { if (empty($_POST[$field_name])) { $errors->add('empty_field', __('ERROR: All fields are required.', APP_TD)); return $errors; } } // check for required anti-spam post data $expected_numbers = array('rand_total', 'rand_num', 'rand_num2'); foreach ($expected_numbers as $field_name) { if (!isset($_POST[$field_name]) || !is_numeric($_POST[$field_name])) { $errors->add('invalid_captcha', __('ERROR: Incorrect captcha answer.', APP_TD)); return $errors; } } // verify captcha answer $rand_post_total = (int) $_POST['rand_total']; $rand_total = (int) $_POST['rand_num'] + (int) $_POST['rand_num2']; if ($rand_total != $rand_post_total) { $errors->add('invalid_captcha', __('ERROR: Incorrect captcha answer.', APP_TD)); } // verify email if (!is_email($_POST['from_email'])) { $errors->add('invalid_email', __('ERROR: Incorrect email address.', APP_TD)); } // verify post $post = get_post($post_id); if (!$post) { $errors->add('invalid_post', __('ERROR: Ad does not exist.', APP_TD)); } if ($errors->get_error_code()) { return $errors; } $mailto = get_the_author_meta('user_email', $post->post_author); $from_name = appthemes_filter(appthemes_clean($_POST['from_name'])); $from_email = appthemes_clean($_POST['from_email']); $subject = appthemes_filter(appthemes_clean($_POST['subject'])); $posted_message = appthemes_filter(appthemes_clean($_POST['message'])); $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteurl = home_url('/'); $permalink = get_permalink($post_id); $message = sprintf(__('Someone is interested in your ad listing: %s', APP_TD), $permalink) . "\r\n\r\n"; $message .= '"' . wordwrap($posted_message, 70) . '"' . "\r\n\r\n"; $message .= sprintf(__('Name: %s', APP_TD), $from_name) . "\r\n"; $message .= sprintf(__('E-mail: %s', APP_TD), $from_email) . "\r\n\r\n"; $message .= '-----------------------------------------' . "\r\n"; $message .= sprintf(__('This message was sent from %s', APP_TD), $sitename) . "\r\n"; $message .= $siteurl . "\r\n\r\n"; $message .= __('Sent from IP Address: ', APP_TD) . appthemes_get_ip() . "\r\n\r\n"; $email = array('to' => $mailto, 'subject' => $subject, 'message' => $message, 'from' => $from_email, 'from_name' => $from_name); $email = apply_filters('cp_email_user_ad_contact', $email, $post_id); APP_Mail_From::apply_once(array('email' => $email['from'], 'name' => $email['from_name'], 'reply' => true)); $resumes = explode(',', $files[0]); $attachments = array(); foreach ($resumes as $resume) { array_push($attachments, WP_CONTENT_DIR . '/themes/classiclean/server/files/' . $resume); } wp_mail($email['to'], $email['subject'], $email['message'], null, $attachments); return $errors; }
function cp_new_user_notification($user_id, $plaintext_pass = '') { global $cp_options; $user = new WP_User($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); // variables that can be used by admin to dynamically fill in email content $find = array('/%username%/i', '/%password%/i', '/%blogname%/i', '/%siteurl%/i', '/%loginurl%/i', '/%useremail%/i'); $replace = array($user_login, $plaintext_pass, get_option('blogname'), home_url('/'), wp_login_url(), $user_email); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // send the site admin an email everytime a new user registers if ($cp_options->nu_admin_email) { $subject = sprintf(__('[%s] New User Registration', APP_TD), $blogname); $message = sprintf(__('New user registration on your site %s:', APP_TD), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s', APP_TD), $user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s', APP_TD), $user_email) . "\r\n"; $email = array('to' => get_option('admin_email'), 'subject' => $subject, 'message' => $message); $email = apply_filters('cp_email_admin_new_user', $email, $user_id, $plaintext_pass); wp_mail($email['to'], $email['subject'], $email['message']); } if (empty($plaintext_pass)) { return; } // check and see if the custom email option has been enabled // if so, send out the custom email instead of the default WP one if ($cp_options->nu_custom_email) { // email sent to new user starts here $from_name = strip_tags($cp_options->nu_from_name); $from_email = strip_tags($cp_options->nu_from_email); // search and replace any user added variable fields in the subject line $subject = stripslashes($cp_options->nu_email_subject); $subject = preg_replace($find, $replace, $subject); $subject = preg_replace("/%.*%/", "", $subject); // search and replace any user added variable fields in the body $message = stripslashes($cp_options->nu_email_body); $message = preg_replace($find, $replace, $message); $message = preg_replace("/%.*%/", "", $message); $email = array('to' => $user_email, 'subject' => $subject, 'message' => $message, 'from' => $from_email, 'from_name' => $from_name); $email = apply_filters('cp_email_user_new_user_custom', $email, $user_id, $plaintext_pass); APP_Mail_From::apply_once(array('email' => $email['from'], 'name' => $email['from_name'])); if ($cp_options->nu_email_type == 'text/plain') { wp_mail($email['to'], $email['subject'], $email['message']); } else { appthemes_send_email($email['to'], $email['subject'], $email['message']); } // send the default email to debug } else { $subject = sprintf(__('[%s] Your username and password', APP_TD), $blogname); $message = sprintf(__('Username: %s', APP_TD), $user_login) . "\r\n"; $message .= sprintf(__('Password: %s', APP_TD), $plaintext_pass) . "\r\n"; $message .= wp_login_url() . "\r\n"; $email = array('to' => $user_email, 'subject' => $subject, 'message' => $message); $email = apply_filters('cp_email_user_new_user', $email, $user_id, $plaintext_pass); wp_mail($email['to'], $email['subject'], $email['message']); } }