Hide comments from non users?

Community Forums Forums Design Tips and Tricks Hide comments from non users?

This topic is: resolved

This topic contains 6 replies, has 2 voices, and was last updated by  braddalton 12 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #36290

    jkstech
    Participant
    Post count: 4

    Seeing as there is no single page or single content template for the News theme, where can I add code to require users to be logged in to see comments?

    I know how to require login to comment, but on my previous theme I was able to set it so comments were hidden unless you were logged in.

    I don’t see where I can do that in the Genesis/News setup. Would this be something to add to the functions as a filter of some sort?

    http://maschinetutorials.com
    #36309

    braddalton
    Participant
    Post count: 7458

    Please paste the code here and i will test it for you. Thanks

    Generally it goes in the child themes functions.php file.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #36313

    jkstech
    Participant
    Post count: 4

    I’m not sure what code to actually use at this point, I’m new to the framework previously I was using a different framework where the child themes actually had single.php and page.php files

    #36316

    braddalton
    Participant
    Post count: 7458

    Wrote this for you and tested in on the Back Country child theme.

    Code not displaying? Grab it from Github Gists

    That’s why Genesis is so good because you use the child themes functions.php for all your PHP customization and never have to worry about finding or losing it.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #36318

    jkstech
    Participant
    Post count: 4

    Awesome, that worked perfectly, thanks!! :)

    Any way to add a messages that says “you must be logged in to view comments” ?

     

    #36326

    braddalton
    Participant
    Post count: 7458

    Wouldn’t be hard to echo some text and HTML.

    http://my.studiopress.com/snippets/


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #36661

    braddalton
    Participant
    Post count: 7458

    There’s lots of different ways you can do this:

    Here’s one method:

    You can also remove the logout link, redirect to a specific url after login or use another tag for loginout.

    <?php wp_loginout(); ?>
    

    Learn more http://codex.wordpress.org/Function_Reference/wp_loginout


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Hide comments from non users?’ is closed to new replies.