Commit 12c10a71 by Arun Raj

Notification only on post publish

parent 2fc04900
...@@ -401,26 +401,29 @@ add_action('transition_post_status', 'func', 10, 3); ...@@ -401,26 +401,29 @@ add_action('transition_post_status', 'func', 10, 3);
function func($new_status, $old_status, $post) function func($new_status, $old_status, $post)
{ {
$category_detail=get_the_category($post->ID);//$post->ID if ( $new_status == 'publish' && $old_status != 'publish' )
//echo "<PRE>";print_r($category_detail);exit; {
$category_detail=get_the_category($post->ID);//$post->ID
$data = array( //echo "<PRE>";print_r($category_detail);exit;
"message" => $post->post_content,
"title" => $post->post_title $data = array(
"message" => $post->post_content,
); "title" => $post->post_title
foreach($category_detail as $cd)
{ );
if($cd->slug=='news') foreach($category_detail as $cd)
{ {
$curl = curl_init( 'http://52.55.205.218:5555/notification/sendnotificationtoall' ); if($cd->slug=='news')
curl_setopt( $curl, CURLOPT_POST, true ); {
curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query($data) ); $curl = curl_init( 'http://52.55.205.218:5555/notification/sendnotificationtoall' );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $curl, CURLOPT_POST, true );
$response = curl_exec( $curl ); curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query($data) );
curl_close( $curl ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec( $curl );
curl_close( $curl );
}
} }
} }
......
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