WordPress new comment notifications on your phone.
Get a push notification when someone comments on your WordPress site, with a button straight to the moderation queue when it needs approval.
Three steps to your first push
Install the recipe
One click in Studio gives you a personal webhook URL.
Paste your URL into WordPress
Add it as a webhook for New comment.
Get a push on your phone
With the text, sound and buttons from the recipe.
How to set up the WordPress new comment webhook
- Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL.
- Copy the PHP snippet from the setup notes below. It already contains your endpoint URL.
- Save it as a new .php file in wp-content/mu-plugins/ on your site (create the folder if it doesn't exist).
- WordPress loads it automatically. Trigger a New comment to test.
- WordPress doesn't send webhooks by itself, so this recipe comes with a small **must-use plugin**. Save the code below as `wp-content/mu-plugins/justpush-new-comment.php` (create the `mu-plugins` folder if it doesn't exist). WordPress loads files there automatically; there's nothing to activate.
- ```php
- <?php
- /**
- Plugin Name: JustPush — New comment
- Description: Sends a push through JustPush Studio when a new comment is posted.
- */
- add_action('comment_post', function ($comment_id, $approved) {
- // Spam and trashed comments aren't worth a push.
- if ($approved === 'spam' || $approved === 'trash') {
- return;
- }
- $comment = get_comment($comment_id);
- // Real comments only, not pingbacks or trackbacks.
- if (!$comment || !in_array($comment->comment_type, array('comment', ''), true)) {
- return;
- }
- $pending = (string) $approved !== '1';
- wp_remote_post('your webhook URL', array(https://••••••••/•••••••• your personal URL, shown after install
- 'blocking' => false, // don't slow the page down waiting for JustPush
- 'timeout' => 3,
- 'headers' => array('Content-Type' => 'application/json'),
- 'body' => wp_json_encode(array(
- 'event' => 'comment.created',
- 'site' => get_bloginfo('name'),
- 'status' => $pending ? 'pending' : 'approved',
- 'author' => $comment->comment_author,
- 'post_title' => get_the_title($comment->comment_post_ID),
- 'excerpt' => wp_trim_words($comment->comment_content, 20),
- 'url' => $pending
- ? admin_url('edit-comments.php?comment_status=moderated')
- : get_comment_link($comment),
- )),
- ));
- }, 10, 2);
- ```
- To stop the notifications, delete the file.
What runs when the webhook arrives
Studio calls handleRequest(request) with the incoming webhook and sends the message it returns. It's yours after install; change anything.
The WordPress comment.created webhook
This is what WordPress sends to your URL for new comment. It is a sample, trimmed to the fields recipes use.
WordPress new comment notifications: questions
Does this work on iPhone and Android?
Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification.
Do I need to write code?
No. Install the recipe in Studio, paste your webhook URL into WordPress and you are done. The code is there if you want to change the text, the sound or the buttons.
Can I change what the notification says?
Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save.
What does it cost?
JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.
WordPress on your phone in two minutes.
Install the recipe, paste one URL, done. Free for 30 days, no credit card required.