if (empty($emails) || !is_array($emails) || empty($board_id) || $board_id === 0) { echo json_encode(array('errors' => 'Sorry, this form submission is not allowed.')); exit; } // breaking this out separately for better legibility if (empty($_POST['form_name']) || $_POST['form_name'] != 'invite-member-send') { echo json_encode(array('errors' => 'Sorry, this form submission is not allowed.')); exit; } //$board_id = 27; // TESTING only //require_once( '../../../../wp-load.php' ); // TESTING only // specify email contents, etc $board_name = get_the_title($board_id); $board_permalink = get_permalink($board_id); $sender_name = get_user_by('id', get_current_user_id())->display_name; $email_html = qb_build_email_html($board_name, $board_permalink, $sender_name); $email_text = qb_build_email_text($board_name, $board_permalink, $sender_name); $email_subject = 'You are invited to join the board "' . $board_name . '"'; $result = array(); /* echo $email_html; echo json_encode( array( 'file_content' => $email_html ) ); exit; */ // load up Mandrill dependencies require_once 'mandrill/send.php'; // emails should already be legit (they were validated on user input), but check again foreach ($emails as $email_to_address) { if ($email_to_address == filter_var($email_to_address, FILTER_SANITIZE_EMAIL) && filter_var($email_to_address, FILTER_VALIDATE_EMAIL)) { /* * qb_generate_invite_url() returns false if an invite was already sent
// move user to "Author" role $new_user_updated = wp_update_user(array('ID' => $new_user_id, 'role' => 'author')); // add meta indicating user has not yet logged in (to trigger the welcome dialog on 1st login) add_user_meta($new_user_id, 'show_tutorial', 1); add_user_meta($new_user_id, 'show_tutorial_board', 1); // there was a problem creating the user if (is_wp_error($new_user_id) || is_wp_error($new_user_updated)) { echo json_encode(array('result' => false, 'errors' => 'There was a problem completing your registration: ' . $new_user_id->get_error_message() . ', ' . $new_user_updated->get_error_message())); // else, send welcome email and auto-sign in the new user } else { /* * Send welcome email */ // load up Mandrill dependencies require_once 'mandrill/send.php'; $email_html = qb_build_email_html('', $user_email); $email_text = qb_build_email_text('', $user_email); $email_subject = 'Welcome to Quoteboard'; $email_to_address = $user_email; $email_to_name = ''; $email_tags = array('welcome'); // send the email (check superadmin ID to avoid mail() errors in localhost) if (SUPERADMIN_USER_ID == 2) { $result[] = mandrill_sendmail($email_html, $email_text, $email_subject, $email_to_address, $email_to_name, $email_tags); } else { $result[] = true; } // if an exception was thrown, notify admin if ($result[0]['mandrill_error']) { qb_notify_admin_mandrill_error($result[0]['mandrill_error'], $email_to_address); break;
// add image file as an attachment $attachment = array('post_mime_type' => $type, 'post_title' => 'User Background', 'post_content' => '', 'post_status' => 'inherit'); // add image to media library $attach_id = wp_insert_attachment($attachment, $mirror['file']); $attach_data = wp_generate_attachment_metadata($attach_id, $mirror['file']); wp_update_attachment_metadata($attach_id, $attach_data); // set background image ID as custom field update_field('field_5320e08f8d2fd', $attach_id, 'user_' . $new_user_id); // set user as author of uploaded image wp_update_post(array('ID' => $attach_id, 'post_author' => $new_user_id)); /* * Send welcome email via Mandrill API */ // load up Mandrill dependencies require_once 'mandrill/send.php'; $email_html = qb_build_email_html($first_name, $user_email); $email_text = qb_build_email_text($first_name, $user_email); $email_subject = 'Welcome to Quoteboard'; $email_to_address = $user_email; $email_to_name = $full_name; $email_tags = array('welcome', 'welcome-facebook'); // send the email $result[] = mandrill_sendmail($email_html, $email_text, $email_subject, $email_to_address, $email_to_name, $email_tags); // if an exception was thrown, notify admin if ($result[0]['mandrill_error']) { qb_notify_admin_mandrill_error($result[0]['mandrill_error'], $email_to_address); } // finish registration require TEMPLATEPATH . '/includes/register-finish.php'; } else { echo json_encode(array('result' => false, 'errors' => 'There was a problem completing your registration: ' . $new_user_id->get_error_message()));
$feedback = sanitize_text_field($_POST['feedback']); if (empty($feedback)) { echo json_encode(array('errors' => 'Please provide some feedback')); exit; } $user_name = sanitize_text_field($_POST['username']); $user_agent = sanitize_text_field($_POST['user_agent']); $page_url = sanitize_text_field($_POST['current_page']); // load up Mandrill dependencies require_once 'mandrill/send.php'; // build and send email $email_to = '*****@*****.**'; $email_to_name = 'Ryan Burney'; $email_subject = 'Beta Feedback'; $email_tags = array('beta-feedback'); $email_html = qb_build_email_html($user_email, $page_url, $user_agent, $feedback); // I don't care about getting text emails here $email_text = $email_html; // send the email $result[] = mandrill_sendmail($email_html, $email_text, $email_subject, $email_to, $email_to_name, $email_tags); // if an exception was thrown, try sending with PHP mail if ($result[0]['mandrill_error']) { if (mail($email_to, 'Beta Tester Feedback', $feedback, 'From: noreply@quoteboard.com')) { echo json_encode(array('result' => 'sent')); exit; } } // return result for jQuery goodness echo json_encode(array('result' => $result)); exit; /*