Search
Close this search box.

wordpress 怎样发邮件,wordpress怎样批量发送邮件,wordpress留言板

<?php
add_action( 'wp_enqueue_scripts', 'razzi_child_enqueue_scripts', 20 );
function razzi_child_enqueue_scripts() {
	wp_enqueue_style( 'razzi-child-style', get_stylesheet_uri() );
}
add_action('wp_ajax_vote_post_lists','add_insert_posts');
add_action('wp_ajax_nopriv_vote_post_lists','add_insert_posts');
add_action('wp_ajax_vote_post_lists','select_insert_posts');
add_action('wp_ajax_nopriv_vote_post_lists','select_insert_posts');
add_action('wp_ajax_get_post_lists','get_insert_postses');
add_action('wp_ajax_nopriv_get_post_lists','get_insert_postses');
function add_insert_posts(){
	if(isset($_POST['action']) && ($_POST['action'] == 'vote_post_lists')){
		$post_json = json_decode(str_replace("\\","",$_POST['datas']));
		$postarr = array(
			'post_author'           => 1, // (int)文章作者的ID,默认为当前登录的用户ID
			'post_title'            => $post_json->names, // (字符串)文章标题,默认为空.
			'post_type'             => 'yuyue', // (字符串)文章类型,默认为『post』.
		);
		$results = wp_insert_post($postarr);
		update_post_meta($results,'timess',$post_json->datetimees);
		update_post_meta($results,'timeuse',$post_json->titles);
		wp_set_post_terms( $results, $post_json->serveType, 'categoryes', true );
		wp_set_post_terms( $results, $post_json->jsName, 'jishi', true );
		wp_set_post_terms( $results,$post_json->timeuse, 'worktimes', true );
		$jishi = wp_get_post_terms( $results, 'jishi', true )[0];
		$worktimes = wp_get_post_terms( $results, 'worktimes', true )[0];
		$to = array(
		   '121180555@qq.com',
			'koodiva1@gmail.com'
		);
		$subject = 'Appointment successful';
		$body = "<p>Name:$post_json->names</p><p>technician:$jishi->name;</p><p>times:$post_json->datetimees $worktimes->name;</p>";
		$headers = array('Content-Type: text/html; charset=UTF-8');
		wp_mail( $to, $subject, $body, $headers );
		$datas = array(
			"code" => 1
		);
		echo json_encode($datas);
		die;
	}
}

function select_insert_posts(){
	if(isset($_POST['action']) && ($_POST['action'] == 'vote_post_lists')){
		$timeArr=get_terms('worktimes', array(
			'orderby' => 'count',
			'hide_empty' => 0
		));
		echo json_encode($timeArr);
		die;
	}
}

function get_insert_postses(){
	if(isset($_POST['action']) && ($_POST['action'] == 'get_post_lists')){
		$getdate = json_decode(str_replace("\\","",$_POST['datas']));
		$timeArr=get_terms('worktimes', array(
			'orderby' => 'count',
			'hide_empty' => 0
		));
		$jishiId = $getdate->jishiId;
		$datetimese = $getdate->datetimees;
		$args = array(
			'post_type' => 'yuyue',
			'orderby'=>'date',
			'order'=>'DESC',
			'posts_per_page' => -1,
			'tax_query'  => array(
				'relation' => 'OR',
				array(
					'taxonomy'         => 'jishi',
					'terms'            => $jishiId
				)
			),
			'meta_query'             => array(
				'relation' => 'OR', 
				array(
					'key'     => 'timess',
					'value'   => $datetimese
				)
			),
		);
		$result = new WP_Query($args);
		foreach($timeArr as $a => $b){
			$b->code = 2;
			foreach($result->posts as $key){
			   $yuyuetimes = get_post_meta($key->ID,'timeuse',true);
				if($b->name == $yuyuetimes){
					array_splice($timeArr, $a, 1);
				}
				
			}
		}
// 				print_r("<pre>");
// 		      print_r($timeArr);
		echo json_encode($timeArr);
		die;
	}
}

发表评论

Optimized by WPJAM Basic