Commit 5fca6a60 by Arun Raj

Notification only on post publish

parent 12c10a71
......@@ -397,37 +397,35 @@ function ws_get_images_urls( $object, $field_name, $request ) {
add_action('transition_post_status', 'func', 10, 3);
add_action('publish_post', 'func', 10, 3);
function func($new_status, $old_status, $post)
function func($post_id)
{
if ( $new_status == 'publish' && $old_status != 'publish' )
{
$category_detail=get_the_category($post->ID);//$post->ID
//echo "<PRE>";print_r($category_detail);exit;
$category_detail=get_the_category($post_id);//$post->ID
//echo "<PRE>";print_r($category_detail);exit;
$post = get_post( $post_id );
$data = array(
"message" => $post->post_content,
$data = array(
"message" => $post->post_content,
"title" => $post->post_title
"title" => $post->post_title
);
foreach($category_detail as $cd)
);
foreach($category_detail as $cd)
{
if($cd->slug=='news')
{
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 );
}
$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 );
}
}
}
......
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