我有一个wordpress网站,我想做一个通知功能。我的问题是如何实时显示通知?
例如,当有人发表评论时,它会立即为所有者显示一个弹出窗口。
我正在考虑使用 ajax 并在 x 秒后调用请求,但我不知道这是否是一个好主意。
要在WordPress中触发评论,您可以使用此钩子。
add_action( 'comment_post', 'show_message_function', 10, 2 );
function show_message_function( $comment_ID, $comment_approved ) {
//function logic goes here for showing your popup
}
希望这对你有帮助。
为,更多信息。
- 插件 API/操作参考/评论帖子
- 通知
- 更好的WordPress通知