Requiring a membership login to leave a comment

May 18, 2014 3:54 pm

How to require a membership login to leave a comment.

After you enable comments for a module:

  1. Go to the Green interface
  2. Click on Layouts
  3. Click on the Modules tab
  4. Filter your module layouts by the "Comments" section
  5. Edit the module layout called [Control]


The default html for [Control] is:


<if 0> <!-- for use when login is required -->
    <div class="membershipLoginWrapper">
        <h1>Login to Leave a Comment</h1>
        <div class="memberLoginBox">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr class="memberUser">
                    <td><span class="itemLabel">Username: </span></td>
                    <td><input type="text" id="uid" value="" size="20" /></td>
                </tr>
                <tr class="memberPassword">
                    <td><span class="itemLabel">Password: </span></td>
                    <td><input type="password" id="pwd" value="" size="20" /></td>
                </tr>
                <tr class="memberSubmit">
                    <td>&nbsp;</td>
                    <td><input type="button" id="login_submit" value="Login" /></td>
                </tr>
            </table>
        </div>
        <p style="color: red;" id="loginStatus">&nbsp;</p>
    </div>
</if>

<if >
    <div id="comment" class="commentWrapper">
        <h2>Leave a Comment</h2>
        <textarea name="comment_text" id="comment_text" cols="80" rows="2"></textarea>
        <div>
            <label for="user_alias">Name: </label>
            <input type="text" name="userid" id="user_alias" value="" />
        </div>
        <div>
            <label for="user_email">E-Mail: </label>
            <input type="text" name="email" id="user_email" value="" />
        </div>
        <div></div>
        <div class="formButtons"><a href="javascript:SaveComment('');">Submit Comment</a></div>
    </div>
</if>

<if 0> <!-- for use when login is required -->
    <script type="text/javascript">InitializeAjaxLogin('membershipLoginWrapper', 'commentWrapper');</script>
</if>

To require users to log into their member account before leaving a comment, change the if statements at the top and the bottom of this html from <if 0> to <if 1>

Save this module layout.

This will now require users to log into their memebrship account before leaving a comment.