Authenticated-Only Comments
Require a Statamic account and the submit comments permission to comment.
#Require authenticated commenters
Open Tools → Addons → Meerkat and enable Only Accept Comments From Authenticated Users. For a deployment default, set publishing.only_accept_comments_from_authenticated_users in config/meerkat.php.
If authenticated comments should still enter the moderation queue, disable Auto Publish Authenticated Users.
Grant the front-end user role the Meerkat submit comments permission. The authenticated-only setting does not grant it automatically.
#Hide guest identity fields
Hide guest identity fields for signed-in users:
1{{ meerkat:form }}
2 {{ if !logged_in }}
3 <p>
4 <label>Name <input type="text" name="name" value="{{ old:name }}" required></label>
5 </p>
6 <p>
7 <label>Email <input type="email" name="email" value="{{ old:email }}" required></label>
8 </p>
9 {{ /if }}
10
11 <p>
12 <label>Comment
13 <textarea name="comment" required>{{ old:comment }}</textarea>
14 </label>
15 </p>
16
17 <input type="text" name="{{ honeypot }}" tabindex="-1" autocomplete="off"
18 style="position:absolute;left:-9999px;">
19
20 <button type="submit">Post comment</button>
21{{ /meerkat:form }}
1<s-meerkat:form>
2 @guest
3 <p>
4 <label>Name <input type="text" name="name" value="{{ $old['name'] ?? '' }}" required></label>
5 </p>
6 <p>
7 <label>Email <input type="email" name="email" value="{{ $old['email'] ?? '' }}" required></label>
8 </p>
9 @endguest
10
11 <p>
12 <label>Comment
13 <textarea name="comment" required>{{ $old['comment'] ?? '' }}</textarea>
14 </label>
15 </p>
16
17 <input type="text" name="{{ $honeypot }}" tabindex="-1" autocomplete="off"
18 style="position:absolute;left:-9999px;">
19
20 <button type="submit">Post comment</button>
21</s-meerkat:form>
Alternatively, use logged_in to show a Log in to comment link to guests:
1{{ if logged_in }}
2 {{ meerkat:form }}
3 {{ partial:comment-form-fields }}
4 {{ /meerkat:form }}
5{{ else }}
6 <p>
7 <a href="/login?redirect={{ current_url | url_encode }}">Log in</a>
8 to join the discussion.
9 </p>
10{{ /if }}
1@auth
2 <s-meerkat:form>
3 @include('comments.form-fields')
4 </s-meerkat:form>
5@else
6 <p>
7 <a href="/login?redirect={{ urlencode(url()->current()) }}">Log in</a>
8 to join the discussion.
9 </p>
10@endauth
#Exclude identity fields globally
Exclude the generated name and email fields from all rendered forms:
1'fields' => [
2 'exclude' => [
3 'name',
4 'email',
5 ],
6],