drgbpq5930 2018-12-02 09:57
浏览 101

Wordpress - 向所有用户发送消息而不是发布作者

I have this snippet for sending a message to the post author when his post is published by using "Front End PM" plugin, So how can i send this msg to all users instead of the post author only?

Thanks in advance.

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用