• Resolved BoxerDog

    (@boxerdog)


    I am using the default theme Twenty Ten 1.1 and have WP_Members activated however when I add the code as per the documentation to hide comments unless the user is a member I get a syntax error. instructions are:

    if you want to restrict comments from being viewed along with posts, add the following at the top your comments.php template file: <?php if (!is_user_logged_in() && !get_post_custom_values(‘unblock’)) { $post->post_password = wpmem_generatePassword(); } ?>

    If I do the above I get a syntax error and the code appears in the post

    Comments are still showing underneath the default registration request on members only pages.Is this a compatibility issue with the theme or am I doing something wrong?

Viewing 7 replies - 1 through 7 (of 7 total)
  • You have the correct code snippet, so it sounds like you have pasted it in incorrectly.

    You did not post what the syntax error you are getting is, so I am guessing that it is something like:

    Parse error: syntax error, unexpected ‘<‘ in E:\web\htdocs\wp\wp-content\themes\twentyten\comments.php on line 1

    The code has its own open and closing php tags so it cannot go inside an opening php tag (such as the <?php at the top of the page). You need to put it at the very top, before the opening php tag.

    Thread Starter BoxerDog

    (@boxerdog)

    Thanks for your reply however I have double checked and have followed the instructions and pasted the code at the head of the comments.php file copies below, and beneath that the error message which is on the live page replacing the comments and note the log in status widget also is no longer shown on the page:

    <[Code moderated as per the Forum Rules. Please use the pastebin]

    Result on live page which has also lost the member log in details widget

    Parse error: syntax error, unexpected ‘>’ in /home/boxpure/public_html/wp-content/themes/twentyten/comments.php on line 2

    Don’t edit the Twenty Ten theme! Your changes will be over-written the next time you upgrade WordPress or the theme. For this reason, it is recommended that you consider creating a child theme for your customisations.

    Thread Starter BoxerDog

    (@boxerdog)

    Hi esmi thanks for the advice and I will make the changes required when I can solve the immediate problem of comments still appearing. If this is not solved then I will probably build the site off the WordPress platform. Hopefully this will not be required.

    Thread Starter BoxerDog

    (@boxerdog)

    cbutlerjr,
    I have noticed that the code supplied in the Quickstart guide to hide comments is different to the code shown on the actual screen shot of the comments.php file. Which code is correct?

    Thanks for pointing that out – the screenshot actually should be updated to the newer code (although that still works as well).

    Based on the error you posted, I suspect that you might have a space or a linebreak in $post->post_password, separating ->. Best to make sure it’s all on a single line.

    Thread Starter BoxerDog

    (@boxerdog)

    Thank you – it was a line break. Works beautifully now. Appreciate your patience and assistance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WP-Members’ is closed to new replies.