Reply To: How to automatically send messages to newly registered users?


Home Forums Front End PM PRO How to automatically send messages to newly registered users? Reply To: How to automatically send messages to newly registered users?

#10347
Shamim Hasan
Keymaster

As you want to send message to users when post is published, you can use following code

function fep_cus_user_post_send_messaage($post){

        $author = get_userdata($post->post_author);
        $author_id = $author->ID;
	$post_title = $post->post_title;
	$post_link = get_permalink($post);
	
	
        if ($post->post_type !== 'post')
                return;
        if ( ! function_exists( 'fep_send_message' ) )
                return;
        // Prepare message data
        $message = array(
             'message_title' => 'title', //change with message title
             'message_content' => 'xxx', //change with message content
             'message_to_id' => $author_id
        );
	
        $override = array(
             'post_author' => 1, //change with message sender id
        );

        // Send message
       fep_send_message( $message, $override );      
}
add_action( 'pending_to_publish', 'fep_cus_user_post_send_messaage', 10, 1 );