ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

require email for commenting but without displaying it

January 19, 2012 10:39pm

Subscribe [3]
  • #1 / Jan 19, 2012 10:39pm

    buridan

    61 posts

    Hi,

    I want to require an email for submitting a comment but without displaying that email. Is this possible?

    Thanks

  • #2 / Jan 20, 2012 6:06am

    zizther

    228 posts

    Hi buridan

    You can easily do this, you can place the email field in the comment form, but when displaying the comments, don’t display the users email, so don’t use {email}.


    Your comment form can look like this

    {exp:comment:form channel=""}
         {if logged_out}
            <label for="comment_name">Name</label>
            <input id="comment_name" name="name" tabindex="5" type="text" value="" />
            
            <label for="comment_email">Email <small>(Will not be shown)</small></label>
            <input id="comment_name" name="email" tabindex="6" type="text" value="" />
        {/if}
            
            <label for="comment_mess">Comment</label>
            <textarea id="comment_mess" name="comment" tabindex="7" cols="" rows=""></textarea>
            
            {if captcha}
                <div id="captcha">
                    Please enter the word you see in the image below:
        
                    {captcha}
    
                    <input name="captcha" tabindex="13" type="text"  value="" size="20" maxlength="20" />
                </div><!-- / #captcha -->
            {/if}
            
            <input tabindex="8" name="submit" type="submit" value="Add Comment" />
    {/exp:comment:form}

    And your list of comments can look like this

    <ul>
         {exp:comment:entries sort="asc"}
            <li>
                <div>{name}</div>
                <div>{comment_date format="%d%S %M %Y"}</div>
                
                {comment}
            </li>
        {/exp:comment:entries}
    </ul>

    Obviously these would be placed inside

    {exp:channel:entries channel="" limit="1" required="yes" disable="member_data|pagination"}
    {/exp:channel:entries}
  • #3 / Jan 20, 2012 12:07pm

    buridan

    61 posts

    Thank you, zizther! I’ll give it a try.

  • #4 / Jan 20, 2012 8:48pm

    Sean C. Smith

    3818 posts

    Buriden,

    Did zizther’s solution work for you? Is there anything else I can assist you with?

    Sean

  • #5 / Jan 21, 2012 2:22pm

    buridan

    61 posts

    I can’t get it to work. Here’s the code I’m using:

    <label for="email">Email <small>(Will not be shown)</small>:</label>
    
    <input type="text" id="name" name="email" value="" size="50" />
  • #6 / Jan 24, 2012 1:45pm

    buridan

    61 posts

    Anyone? Please.

  • #7 / Jan 25, 2012 8:50pm

    buridan

    61 posts

    I see the mistake I made…

    zizther, your solution worked great. Thanks again.

  • #8 / Jan 26, 2012 5:50pm

    Sean C. Smith

    3818 posts

    Buridan,

    I’m glad to see that Zizther’s solution worked for you. Is there anything else I can assist you with?

    Sean

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases