• Hello!

    I am a teacher and am using my website as part of my class. I’d like students to post on the site BUT for security/privacy reasons when the comment gets approved (I moderate all comments) the student’s name gets stripped out. I would need the student name to display in the moderation queue so I know who gets credit. I understand I can manually block out the name but a plugin would save me much for time.

    Does such a plugin exist?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Manually stripping out names? Absurd! You need a solution ??

    I’m not knowledgeable of available plugins, but I’m skeptical. It wouldn’t take much code to strip out commenter data once the comment is approved, but since that would be destroying data, I’m unsure why anyone would publish such a plugin.

    A better approach would be to simply suppress identifying information on the display page, while maintaining the data for access by admins. Unfortunately, how to do this is theme dependent, so infeasible for a generic plugin.

    Depending on what theme you’re using, suppressing the display of identity can be anything from ridiculously simple to rather a PITA. If such an approach would work for you, tell me what theme you’re using. I might be able tell you exactly what to do. Or at least tell you in general terms what’s involved.

    Also, do students (or anyone who should not know identities) have access to the back end? That can complicate things depending on what capabilities they have simply because there’s more places that display the information to consider. Or is your concern only for the public front end, that it’s OK for students to know who commented through the back end?

    Thread Starter Pcosta88

    (@pcosta88)

    BCworkz:
    I would need to see who wrote the comment in the moderation queue (so that student can get credit) and when I publish it I would need the name of the student stripped out (for privacy reasons).

    You are right about doing it manually but it becomes more of PITA if I have to do it for all 150 of my students.

    To answer your question:
    1. I am currently running twenty-twelve theme
    2. No, students do not have access to the back-end
    3. My concern is on the front-end

    Any general pro-tips or pointers would be good to get started. I’ve written some custom plugins before BUT they were simple and I am not sure how complicated this one would be.

    Moderator bcworkz

    (@bcworkz)

    You’re in luck, twentytwelve is easy to customize output to the frontend. It uses a pluggable callback function to generate each comment. You simply copy the original function declaration into the functions.php file of a child theme and edit as needed.

    If you don’t already have a child theme, it’s easy to setup, it’s all in the Codex. Besides the required style.css file, create a new, empty functions.php file. Locate the twentytwelve_comment() declaration in twentytwelve’s functions.php and copy it to your child theme’s version. It’s at lines 295-355, you don’t need the if ( ! function_exists( 'twentytwelve_comment' ) ) : line and the associated endif; Do not change the function name either.

    Identify the portion responsible for outputting the comment author information and comment it out. It’s the first printf() block. That should do it! I haven’t tested this myself, so I may have missed something. If so, locate the offending code and edit or comment out as needed.

    Activate you child theme as the site’s theme, you shouldn’t notice any difference other than the comment author names have disappeared.

    It’d be a good idea to review the page’s HTML code to insure all traces of comment author data have been eliminated, there’s sometimes data here that does not appear in the normal browser display.

    The authors will always be visible to anyone in the backend with adequate capabilities, no data is destroyed, and yet the information is secure from site visitors.

    Thread Starter Pcosta88

    (@pcosta88)

    I created a new child-theme, added a CSS stylesheet (with no changes on it) and added a function.php

    Hey I took your advice but it does not seem to be working.
    I edited out the items:
    https://pbrd.co/1nQkk0c
    And when I ran a test comment as a different user for my localhost site it still showed-up:
    https://pbrd.co/1nQklRD

    Any other suggestions or should I just mess around until something breaks?

    Moderator bcworkz

    (@bcworkz)

    The correct filename is functions.php, plural! Without that ‘s’, the theme loader just ignores your file.

    You say you added a CSS stylesheet with no changes. Let’s make sure we’re on the same page here. Your child theme style.css should not have any actual CSS directives on it, it shouldn’t be more than a couple dozen lines at most, consisting of a data header in comment form that names the theme and specifies the parent template. The only actual code should be an @import url() line referencing the parent’s style.css file.

    It kind of sounds like you copied the entire twentytwelve stylesheet. No need for that, the import line takes care of that.

    In summary, your child theme should have two files, the style.css mentioned, and functions.php with an ‘s’. The functions.php file should contain ( besides the opening <?php ) a copy of twentytwelve_comment() function declaration with the first printf() block commented out.

    You can make a screenshot.png file as well so your theme has a picture in the theme menu, not mandatory but nice.

    Activate your child theme.

    The comment author name should now disappear.

    Beware of the names showing up elsewhere, such as in the “Recent Comments” widget. Editing widgets is more involved than child themes, but it isn’t too bad. Let me know if you need to do this.

    As for messing around until something breaks, that’s a good way to learn! Just be sure you can revert to functional files when thing go bad. It helps to at least have half a clue about what you’re doing, but I’ve discovered interesting things while being completely clueless about something ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Looking for a comment name stripper’ is closed to new replies.