Fox Auth User Comment Box

Summary: Posting comments for logged in users only, using Fox
Version: 2011-12-23
Prerequisites: fox.php, foxdelete.php, authuser.php
Maintainer: HansB?
Categories: Fox Security CMS Forms
Users: (view? / edit)

Questions answered by this recipe

How to add comments for logged in users only, using Fox All sections are optional, you can remove those that do not apply to your recipe, and add new ones.


This is an example for setting up a comment form for posting comments for logged in users only, using Fox and AuthUser


Prerequisites: install AuthUser?, Fox and FoxDelete.

Add following to config.php, $FoxPagePermissions should be set for the group or page in which comments should be posted (in this example it is for all pages in group Test):

if ($AuthId) {
  $Author = $AuthId;

Conditions['authuser'] = '\$GLOBALS["AuthId"]==\$condparm';

$FoxPagePermissions['Test.*'] = 'add,delete';



Page Site.AuthUser should be configured with user ids and their passwords, or users and passwords set up in a different way.

Add to Site.FoxForms this Fox comment form code:

(:fox cbox put=below mark=!!Comments template=Site.FoxTemplates#comment:)
Subject: (:input text heading size=60:)
'''Your Comment:'''
(:input textarea comment cols=60 rows=6:)
(:input hidden author value='{$AuthId}' :) (:input submit post "Add Comment":)
(:foxend cbox:)

Add to Site.FoxTemplates this comment template:

(:div1 class=messagehead:)
[-{$$(date d.m.Y - H:i)}-] &nbsp; (:if expr auth admin or authuser {$$author}:){[foxdelrange]}(:if:)

Add to each page or the GroupHeader (or GroupFooter) this markup for the comment form:

(:if authid:)Logged in as '''{$AuthId}''' - [-[[{*$FullName}?action=logout| (log out)]]-]
(:foxform Site.FoxForms#commentform :)
(:else:)Please [[{*$FullName}?action=login|log in]] to add comment!

Add to pub/css/local.css some styles (taken from CommentBoxPlus? styles css):

/* styling of commentbox entries */
#message { clear:both; }
.messagehead, .journalhead {
            margin:1em 0 0 0;
            padding:0 0 0 3px;
            border:1px solid #ccc;
.messageitem, .journalitem {
            border-left:1px solid #ccc;
            border-right:1px solid #ccc;
            border-bottom:1px solid #ccc;
.messagehead { background:#f0f0f0; }
/*use the following if message head should be same as message item */
/* .messagehead { background:#eef; border-bottom:none; } */
.messageitem { background:#f7f7f7; }


  • The comment box form is set up for use with AuthUser?.
  • It has no author field, as author is set via login with the AuthId of

the user.

  • You need to log in to see the comment form.
  • The delete link will only show for the logged in user's posts, and

for the admin (logged in as admin).

  • You may wish to tighten security by making sure only logged in users are allowed to post, but not allowed to fully edit pages. Follow instructions for AddingAuthLevels?


Change log / Release notes

  • 2011-12-23: initial write up

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also



See discussion at FoxAuthUserCommentBox-Talk?