Commit f4e3720b by Arun Raj

Mail configured for a new entry in featured content

parent bdce90b6
...@@ -432,7 +432,7 @@ function func($post_id) ...@@ -432,7 +432,7 @@ function func($post_id)
function wpdocs_run_on_publish_only( $new_status, $old_status, $post ) { /*function wpdocs_run_on_publish_only( $new_status, $old_status, $post ) {
if ( 'publish' === $new_status && 'publish' !== $old_status ) if ( 'publish' === $new_status && 'publish' !== $old_status )
{ {
$category_detail=get_the_category($post->ID);//$post->ID $category_detail=get_the_category($post->ID);//$post->ID
...@@ -459,6 +459,58 @@ function wpdocs_run_on_publish_only( $new_status, $old_status, $post ) { ...@@ -459,6 +459,58 @@ function wpdocs_run_on_publish_only( $new_status, $old_status, $post ) {
} }
} }
add_action( 'transition_post_status', 'wpdocs_run_on_publish_only', 10, 3 );*/
function wpdocs_run_on_publish_only( $new_status, $old_status, $post){
global $wpdb;
$customers = $wpdb->get_results("SELECT * FROM wp_newsletter");
if ( 'publish' === $new_status && 'publish' !== $old_status )
{
$category_detail=get_the_category($post->ID);//$post->ID
$data = array(
"message" => $post->post_content,
"title" => $post->post_title
);
foreach($category_detail as $cd)
{
if($cd->slug=='news')
{
$curl = curl_init( 'http://52.55.205.218:5555/notification/sendnotificationtoall' );
curl_setopt( $curl, CURLOPT_POST, true );
curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query($data) );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec( $curl );
curl_close( $curl );
}
}
foreach($customers as $customer){
$email = $customer->email;
$cat = get_the_term_list( $post->ID,'wpfcas-category');
$cat = strip_tags($cat);
//echo $cat;exit;
if(($cat == "Guruvachanam")|| ($cat == "Guruvaakku") || ($cat == "Guruvarul"))
{
$body = sprintf( 'Hey there is a new entry in %s!
See <%s>',$cat,
get_home_url()
);
wp_mail( $email, 'New entry!', $body );
}
}
}
}
add_action( 'transition_post_status', 'wpdocs_run_on_publish_only', 10, 3 ); add_action( 'transition_post_status', 'wpdocs_run_on_publish_only', 10, 3 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment