Wordpress-发送消息给所有用户,而不是帖子作者

时间:2018-12-02 09:57:07

标签: php wordpress message

我有这个代码片段,用于在使用“ Front End PM”插件发布帖子时向帖子作者发送消息,那么我该如何向所有用户而不是帖子作者发送此味精? >

先谢谢了。

add_action( 'publish_post', 'fep_cus_user_publish_send_messaage', 10, 2 );

    function fep_cus_user_publish_send_messaage( $ID, $post ){

        if ( ! function_exists( 'fep_send_message' ) )
        return;


    //Check Send
    $send_email = get_post_meta( $post->ID, 'fep_send_email', true );
    if ( ! empty( $send_email ) ) return;


        $message = [];

        $message['message_to_id'] = $post->post_author; // Post author ID. 
        $name = get_the_author_meta( 'display_name', $post->post_author );
        $title = $post->post_title;
        $permalink = get_permalink( $ID ); 
        $message['message_title'] = sprintf( 'Published: %s', $title );
        $message['message_content'] = sprintf ('Congratulations, %s! Your article “%s” has been published.', $name, $title );
        $message['message_content'] .= sprintf( 'View: %s', $permalink );
        $message['message_content'] .= sprintf( 'This is an automatic message, to let you know your post is published, and qualified for our quality standard!' );
        $override = array('post_author' => 1);//change with message sender id  

    //Set Post Meta
    update_post_meta( $post->ID, 'fep_send_email', '1' );

        // Send message
        fep_send_message( $message, $override );  

    }

0 个答案:

没有答案