The MU forums have moved to WordPress.org

comments for any registered user? (11 posts)

  1. tbarros
    Member
    Posted 17 years ago #

    Hello:

    It looks like a user registered with or without subscriber role (even without a blog associated) can comment in any blog. Is this right ? shouldn't a user can comment only in the blogs where he's a subscriber (I mean if you restrict comments only to registered users ?

    Thanks in advance
    Tomás

  2. drmike
    Member
    Posted 17 years ago #

    Registered users are site wide, not just subscribers assigned to a specific blog.

    At least that's how it is in WP.com land.

  3. donncha
    Key Master
    Posted 17 years ago #

    He has a point. If you want to limit comment posting to those registered on your blog the add this code to wp-comments-post.php around line 25:
    $user = wp_get_current_user();

    if( get_option('comment_registration' ) && ( false == $user->ID || false == $user->has_cap( "level_0" ) ) ) {
    wp_die( __('Sorry, you must be logged in and registered on this blog to post a comment.') );
    }

  4. tbarros
    Member
    Posted 17 years ago #

    Many thanks,

    But.. where in the code you are proposing it is check if the user is subscriber for this specific blog ? (I understand as well that the 'level_*'is deprecated).

    In fact, I'm trying to understand the roles/capabilities in the code. In the administration works well in a per blog basis (I mean, one login then administration for blogs where you are administrator, editor menu for blogs where you are editor, and so on..).

    Anyway, at least to me looks more natural to have subscribtion per blog.. specially because when you set the role you do it in a specific blog.. then I'll suggest to the wordpress mu developers to consider that.

    Tomás

    PS: I'm doing a plugin so students can send their homework of a class only when registered as student in such class (where each class has its own blog).

  5. donncha
    Key Master
    Posted 17 years ago #

    Checking for level_0 was the easiest way I found to check for a registered user.
    I suppose you could try:
    if( current_user_can('read') == false )
    wp_die( __( "Sorry, you must...." ) );

    Does that work? You'll have to modify each theme's comments.php too so that the comment form isn't displayed. Look for the string "comment_registration". You'll have to modify the if() statement and add the current_user_can() check.

    I don't think this will go into WordPress MU itself however. It's the opposite of what a lot of users expect and are used to.

  6. andrea_r
    Moderator
    Posted 17 years ago #

    Yep. My users, for one, are thrilled.

    Easier than hacking woudl be to find one of the postviewlevel* plugins and get that working under MU.

    Restricts posts/comments to users at a certain level, including subscriber.

  7. tbarros
    Member
    Posted 17 years ago #

    Yes, the "if( current_user_can('read') == false )" works, but site wide.

    If the user is subscriber of any blog, he has the capability read for all the blogs in the site, and I want the user to comment only in the blogs he's subscriber

    Tomas

  8. mrjcleaver
    Member
    Posted 17 years ago #

  9. mrjcleaver
    Member
    Posted 17 years ago #

    This was closed - wontfix. Someone should write a plugin.

  10. Farms2
    Member
    Posted 17 years ago #

    Hallo there.

    Has there been any progress on this?

    A plugin / hack that limited the ability to comment to only users who had blogs / accounts on that WPMU install would rock my world several times over.

    It might also get WPMU it's first (I think) major media organisation use... fingers crossed :)

    Cheers, James

  11. Farms2
    Member
    Posted 17 years ago #

    FYI I messed around with this for a heck of a long time before figuring out a ridiculoulsy simple sitewide solution for 1.0:

    Simply, in commensts.php of the theme you're using (this is with Tarski) where it checks if the registration for comments option is ticked, delete the registration but so it looks like this:

    <div id="respond">

    <?php // if registration is mandatory
    if ( !$user_ID ) : ?>

    You must be registered and /wp-login.php">logged in to post a comment.
    </div>

    Only users who are registered and logged in can now see the comments field or make a comment.

About this Topic