• I see that the read/unread status is set by CSS classes and I have used this to great effect to really highlight the posts that a user has not read (rather than relying on the user visiting their profile page to find new posts).

    The only problem with this is that posts default to unread if the user isn’t logged in. This would be fine if I used the read css class to somehow make the post less visible, but since I am trying to make it more visible, the page looks odd if you have never logged in.

    Would it be possible to add code and/or an option to set the CSS only when a user is logged in?

    https://www.ads-software.com/extend/plugins/bbpress-mark-as-read/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter fredd500

    (@fredd500)

    Managed to do this myself by editing the plugin code.

    diff --git a/bbp-mark-as-read.php b/bbp-mark-as-read.php
    index b08d0e3..1a79a6d 100644
    --- a/bbp-mark-as-read.php
    +++ b/bbp-mark-as-read.php
    @@ -380,11 +380,15 @@ class BBP_Mark_As_Read {
                    global $post, $user_ID;
                    if( 'topic' != get_post_type( $post ) )
                            return $classes;
    -
    -               if( $this->is_read( $user_ID, $post->ID ) )
    -                       $classes[] = 'bbp-topic-read';
    -               else
    -                       $classes[] = 'bbp-topic-unread';
    +
    +               if( is_user_logged_in() ) {             // Don't bother unless the user is actually logged in - CPM
    +                       if( $this->is_read( $user_ID, $post->ID ) ) {
    +                               $classes[] = 'bbp-topic-read';
    +                       }
    +                       else {
    +                               $classes[] = 'bbp-topic-unread';
    +                       }
    +               }
    
                    return $classes;
            }

    Any chance this could be incorporated in to the master code?

    Plugin Author Pippin Williamson

    (@mordauk)

    That is a good idea, I will try and make the update.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display unread posts only to logged in users’ is closed to new replies.