php - Send Notification when new post is published in wordpress -
right now, sending notification android application users when new post created in wordpress. issue that, sends notification when draft created , post updated. condition should put send notification when new post published ?
here code, located in wp-admin/includes/post.php
function _wp_translate_postdata( $update = false, $post_data = null ) { if ( $update) $post_data['id'] = (int) $post_data['post_id']; $post_id = $post_data['id']; global $wpdb; $sel2 = mysql_query("select * gcm_users"); while($data1 = mysql_fetch_assoc($sel2)) { $key = $data1['gcm_regid']; include_once '../blogdroid/config.php'; include_once '../blogdroid/gcm.php'; $gcm = new gcm(); $sel = mysql_query("select * ".$wpdb->prefix."posts id='$post_id'"); $data = mysql_fetch_assoc($sel); $pname = $data['post_title']; $registatoin_ids = array($key); if($pname != 'auto draft') { $message = array("blog" => 'new blog arrived '.$pname ); $result = $gcm->send_notification($registatoin_ids,$message); } } }
as mentioned earlier, shouldn't edit wp core files. want, can create function , hook post status transitions, codex has perfect explanation how work.
Comments
Post a Comment