HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Fetching New Users From Database

R_JR_J Ex-FanboyMunich Moderator

I have been asked via PM if I can give support and as I have explained recently, I'm willing to do so, but I think asking in a public help forum for help via PM feels wrong to me. So here is the task and my reaction.

I have been asked to provide some Smarty snippet which makes the recent registered users available. I don't think that approach is wise, since Vanilla is moving towards Twig and writing themes for Vanilla usually doesn't involve dealing too much with Smarty at all. But I haven't been asked for my opinion on Smarty...

There is plugin called ReuasableStats which provides some metrics which then should be available as Smarty snippets. I have no time for working on a detailed and really working solution, but here is what I came up with and what might help getting you started...

That snippet needs to be included in the themehooks file. After that you should be able to access the info "somehow" as "new_users". I really don't know how handling an array with Smarty would work. As I said before, that wouldn't be my approach...

   public function base_render_before($sender) {
       $newUsers = Gdn::cache()->get('NewUsers');

       if ($newUsers === Gdn_Cache::CACHEOP_FAILURE) {
           $newUsers = Gdn::sql()
               ->where('Banned >' ,0)
               ->where('Deleted >', 0)
               ->orderBy('DateInserted', 'desc')
               [Gdn_Cache::FEATURE_EXPIRY => 2 * 60]
       $sender->setData('new_users', $newUsers);

The code is untested by the way, but I'm quite short in time, sorry...

Sign In or Register to comment.