Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

disable "new" attention first login

Is there a way when a member registers and logs in for the first time, all the "new" what are displayed in the topics can be set on disabled?
Situation now: when you login and someone has commented on one of the topics or posted a new topic, in the discussion area there is a "new" displayed for attention there is a new comment posted on this topic or there is a new topic started. And i really want to keep it that way. But when you register as a new member and login for the first time, of course, everything is displayed as "new". So is it possible for first login that all the existing topics are not being displayed as "new" and for that member only the topics posted after her/his login are displayed as "new"?

Tagged:

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    By default every discussion is new and I think that's the way how it should be because it makes sense. If you register as a new user you are a new user. But there should be a way to mark all discussions as read.

    In order to mark all as read, you would have to fill the table UserDiscussion with the right information. Here is a short way how to achieve it. You could try creating a plugin for that ;) It would have to hook somewhere in the registration process.

    You will need to have the UserID of the current user. That's easy:

    $Session = Gdn::Session();
    $UserID = $Session->UserID;
    

    Afterwards you will have to fire an sql to fill the table with the "read" information.

    $Px = Gdn::Database()->DatabasePrefix;
    
    $Sql = <<<EOT
    INSERT INTO
       {$Px}UserDiscussion (
          -- fetch all discussion...
          SELECT
               {$UserID}
             , DiscussionID
             , NULL -- score
             , CountComments
             , DateLastViewed
             , 0 -- dismissed
             , 0 -- bookmarked
          FROM
             {$Px}Discussion
          -- ... that are not already in the table
          WHERE DiscussionID NOT IN (
             SELECT
                DiscussionID
             FROM
                {$Px}UserDiscussion
             WHERE
                UserID = {$UserID}
          )
       )
    EOT;
    

    And if you really create a plugin, I would suggest you leave it to the old logic and just create a plugin that can mark either all discussions or all discussions of a category as read.

  • Thank you for your post @R_J
    I already use the "AllViewed" plugin and it works good. Maybe it is a better idea to make a little changes in that plugin for myself so that a new user when logged in for the first time does not necessarily has to click on "AllViewed" . I will have a look at it and try some things...thanks for answering

  • hgtonighthgtonight ∞ · New Moderator

    @jackmaessen, it should be fairly easy to mark all as read using the all viewed plugin. You could capture the 'RegistrationSuccessful' event on the entry controller which will take care of all newly registered members. Then you need to actually call the mark all viewed functionality defined by the plugin.

    Adding something like this to the /plugins/AllViewed/class.allviewed.plugin.php file (anywhere in the class definition) should get you started.

    public function EntryController_RegistrationSuccessful_Handler($Sender) {
      $UserModel = Gdn::UserModel();
      $UserModel->UpdateAllViewed();
    }
    

    Remember to disable/enabled plugins to force update the cache for new plugin event handlers.

    If you are using the registration approval method then you have to work around that. Approval fires a different event (AfterApproveUser) on a different controller.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    peregrinejackmaessenShadowdare
  • Awesome! @hgtonight This works perfect. Thank you very much for support.

    hgtonight
Sign In or Register to comment.