function userNotification($post_id) {
global $wpdb;
$post = get_post($post_id);
//$usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
//$users=array();
//foreach($usersarray as $user){
//$users[]=$user->user_email;
//}
//$userarray = implode(",", $users);
//Getting emails from formidable form
//it.form_id is the field name
$items = FrmEntry::getAll(array('it.form_id' => 4));
$emails=array();
foreach($items as $item){
$emails[]="Bcc: ".FrmProEntriesController::get_field_value_shortcode(array('field_id' => 34, 'entry' => $item->id));
}
//$userarray = implode(",", $emails);
if (!(defined( 'REST_REQUEST') && REST_REQUEST )) {
$subject = $post->post_title;
$content=$post->post_content;
$content=$content."<p>Article link at <a href=".get_permalink( $post_id ).">Link to article post</a></p>";
$headers = array('Content-Type: text/html; charset=UTF-8');
foreach($emails as $email){
$headers[]=$email;}
wp_mail("",$subject,$content,$headers);
}
}
add_action('publish_post', 'userNotification',10);