-
Notifications
You must be signed in to change notification settings - Fork 0
Subscribing without commenting
Some readers might want to follow a discussion without joining it. There are three ways to offer that, all rendering the same form and all subject to the same checks.
A subscription made this way always covers every comment on the post — there is no comment of their own for replies to hang off.
Insert Comment subscription in the post. One setting, the heading; leave it empty for the default.
The block renders on the server, so the editor shows a placeholder rather than a live form.
[happy_comments_subscribe]
[happy_comments_subscribe title="Follow this discussion"]
For themes placing it by hand:
happy_comments_subscribe_form();
happy_comments_subscribe_form( [ 'title' => 'Follow this discussion' ] );
// Return instead of printing.
$html = happy_comments_subscribe_form( [], false );happy_comments_has_subscribe_form() tells you whether the form would render, so you can decide about a wrapper without rendering it twice:
if ( happy_comments_has_subscribe_form() ) {
echo '<section class="follow">';
happy_comments_subscribe_form();
echo '</section>';
}All three return nothing when comments are closed on the post. A closed discussion has nothing to notify anybody about. Override with happy_comments_subscribe_form_available.
The comment form has a natural brake: the confirmation email only goes out once the comment is approved, so it cannot be used to mail strangers. The standalone form has no such gate — it takes an address from an anonymous visitor and mails it.
So four checks stand in front of it:
| Check | Default |
|---|---|
| Honeypot field | — |
| Minimum time between the page loading and the form being sent | 3 seconds |
| Maximum age of a rendered form | 24 hours |
| Submissions per IP address | 5 per hour |
| Cooldown per address and post | 15 minutes |
All adjustable through happy_comments_throttle_limit.
The last one matters most. An IP cap bounds one attacker and does nothing against a botnet; the cooldown is keyed on the address being subscribed, so it bounds what any one person can be made to receive no matter how many machines are involved.
Rejections are silent. Every submission gets the same message, whether the address is new, already subscribed, already confirmed, or blocked — otherwise the form becomes a way to ask whether a given address is subscribed to a given post.