/** * Send email after report success */ public function et_reported_email($thread_id, $report_message) { global $current_user; if ($thread_id && $report_message) { $thread = get_post($thread_id); $user_send = get_users('role=administrator'); foreach ($user_send as $user) { $user_email = $user->user_email; $message = ae_get_option('report_mail_template'); /* ============ filter placeholder ============ */ $message = str_ireplace('[display_name]', $user->display_name, $message); $message = str_ireplace('[thread_title]', $thread->post_title, $message); $message = str_ireplace('[thread_content]', $thread->post_content, $message); $message = str_ireplace('[thread_link]', get_permalink($thread_id), $message); $message = str_ireplace('[report_message]', $report_message, $message); $message = str_ireplace('[blogname]', get_option('blogname'), $message); $message = et_filter_authentication_placeholder($message, $user->ID); $subject = '[#' . $thread_id . ']' . __("There's a new report ", ET_DOMAIN); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: " . get_option('blogname') . " < " . $current_user->user_email . "> \r\n"; if ($user_email) { $test = wp_mail($user_email, $subject, $message, $headers); } } } }
public function handle_posts() { global $current_user; /** * * - PREVENT USERS ACCESS TO PENDING PAGE EXCEPT ADMIN * - * - @package QAEngine * - @version 1.0 * **/ if (is_page_template('page-pending.php') && !current_user_can('manage_options')) { wp_redirect(home_url()); exit; } /** * * - PREVENT USERS ACCESS TO CONTENT PAGE IF OPTION IS ACTIVE * - * - @package QAEngine * - @version 1.0 * **/ if (ae_get_option("login_view_content")) { //var_dump(!is_page_template( 'page-intro.php' ) && !is_user_logged_in()); if (!is_page() && !is_singular('post') && !is_user_logged_in()) { wp_redirect(et_get_page_link('intro')); exit; } } /** * * - REDIRECT USERS TO QUESTIONS LIST PAGE IF ALREADY LOGGED IN * - * - @package QAEngine * - @version 1.0 * **/ if (is_page_template('page-intro.php')) { if (is_user_logged_in()) { wp_redirect(get_post_type_archive_link('question')); exit; } } /** * * - REDIRECT TO SEARCH PAGE * - * - @package QAEngine * - @version 1.0 * **/ if (isset($_REQUEST['keyword'])) { $keyword = str_replace('.php', ' php', $_REQUEST['keyword']); $link = qa_search_link(esc_attr($keyword)); wp_redirect($link); exit; } /** * * - COUNT QUESTION VIEW * - * - @package QAEngine * - @version 1.0 * **/ if (is_singular('question')) { global $post, $user_ID; if (ae_get_option("login_view_content") && get_user_meta($user_ID, 'register_status', true) == "unconfirm") { wp_redirect(add_query_arg(array('confirm' => 0), home_url())); exit; } if ($post->post_status == 'publish') { $views = (int) QA_Questions::get_field($post->ID, 'et_view_count'); $key = "et_post_" . $post->ID . "_viewed"; if (!isset($_COOKIE[$key]) || $_COOKIE[$key] != 'on') { QA_Questions::update_field($post->ID, 'et_view_count', $views + 1); setcookie($key, 'on', time() + 3600, "/"); } } } /** * * - INSERT A QUESTION * - @param string $post_title * - @param string $post_content * - @param string $question_category * - @package QAEngine * - @version 1.0 * **/ if (isset($_POST['qa_nonce']) && wp_verify_nonce($_POST['qa_nonce'], 'insert_question')) { global $current_user; $cats = array('qa_tag' => $_POST['tags'], 'question_category' => $_POST['question_category']); $result = QA_Questions::insert_question($_POST['post_title'], $_POST['post_content'], $cats); do_action('qa_insert_question', $result); if (!is_wp_error($result)) { wp_redirect(get_permalink($result)); exit; } } /** * * - INSERT A COMMENT TO QUESTION * - @param int $post_id * - @param array $author_data * - @param array $comment_data * - @package QAEngine * - @version 1.0 * **/ if (isset($_POST['qa_nonce']) && wp_verify_nonce($_POST['qa_nonce'], 'insert_comment')) { global $current_user; $result = QA_Comments::insert(array('comment_post_ID' => $_POST['comment_post_ID'], 'comment_content' => $_POST['post_content'])); do_action('qa_insert_comment', $result); if (!is_wp_error($result)) { wp_redirect(et_get_last_page($_POST['comment_post_ID'])); exit; } } /** * Confirm User */ if (isset($_GET['act']) && $_GET['act'] == "confirm" && $_GET['key']) { $user = get_users(array('meta_key' => 'key_confirm', 'meta_value' => $_GET['key'])); global $qa_confirm; $qa_confirm = update_user_meta($user[0]->ID, 'register_status', ''); $user_email = $user[0]->user_email; $message = ae_get_option('confirmed_mail_template'); $message = et_filter_authentication_placeholder($message, $user[0]->ID); $subject = __("Congratulations! Your account has been confirmed successfully.", ET_DOMAIN); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: " . get_option('blogname') . " < " . ae_get_option('send_mail_from', '*****@*****.**') . "> \r\n"; if ($qa_confirm && $user_email) { wp_mail($user_email, $subject, $message, $headers); } } }
public function user_register_mail($user_id, $role = false) { $user = new WP_User($user_id); $user_email = $user->user_email; if (ae_get_option('user_confirm')) { $message = ae_get_option('confirm_mail_template'); } else { $message = ae_get_option('register_mail_template'); } $message = stripslashes($message); $message = et_filter_authentication_placeholder($message, $user_id); $subject = sprintf(__("Congratulations! You have successfully registered to %s.", ET_DOMAIN), html_entity_decode(get_option('blogname'))); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: " . html_entity_decode(get_option('blogname')) . " < " . ae_get_option('send_mail_from', '*****@*****.**') . "> \r\n"; wp_mail($user_email, $subject, $message, $headers); }
/** * Resend confirm email * @param * @return * @author tatthien * @since 1.5.6 */ public function resend_confirm_email() { $resp = array(); $user_id = $_REQUEST["ID"]; $register_status = get_user_meta($user_id, "register_status", true); $key_confirm = get_user_meta($user_id, "key_confirm", true); if (!empty($register_status) && $register_status == "unconfirm") { // Send email $user = new WP_User($user_id); $user_email = $user->user_email; $message = ae_get_option('confirm_mail_template'); $message = stripslashes($message); $message = et_filter_authentication_placeholder($message, $user_id, $key_confirm); $subject = sprintf(__("You have recieved a confirmation email from %s.", ET_DOMAIN), html_entity_decode(get_option('blogname'))); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: " . html_entity_decode(get_option('blogname')) . " < " . ae_get_option('send_mail_from', '*****@*****.**') . "> \r\n"; wp_mail($user_email, $subject, $message, $headers); $resp = array("success" => true, "msg" => __("Successfully resend the confirmation email.", ET_DOMAIN)); } else { $resp = array("success" => false, "msg" => __("Your account has been activated.", ET_DOMAIN)); } return $resp; }