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.

Any way to show users join date in posts?

hi, is there any way to make it show users join date beside the users info when they post? like "Joined: December 2014"

Comments

  • hi, i tried the above and when i tried to enable the addon it gave an error saying

    "There was an error getting the class methods."

  • NozumiNozumi New
    edited December 2014

    hmm interestingly enough it does display the "Join Date:" so it does work even though it gave me that error thanks for making this

  • peregrineperegrine MVP
    edited December 2014

    @Nozumi said:
    hi, i tried the above and when i tried to enable the addon it gave an error saying

    "There was an error getting the class methods."

    it is because of the way you cut and pasted things.

    make sure there is a blank line between

    );

    class JoinDatePlugin extends Gdn_Plugin {

    also don't allow any leading spaces before <php

    BAD - if your cut and pastw looks like this in your file.

    
        <?php if (!defined('APPLICATION')) exit();
        $PluginInfo['JoinDate'] = array(
        'Name' => 'JoinDate',
        'Version' => '1',
        'Author' => 'Bleistivt'
        );
        class JoinDatePlugin extends Gdn_Plugin {
        public function DiscussionController_CommentInfo_Handler($Sender) {$this->AddJoined($Sender);}
        public function DiscussionController_DiscussionInfo_Handler($Sender) {$this->AddJoined($Sender);}
        protected function AddJoined($Sender) {
        echo ''.T('Joined').': '.
        Gdn_Format::Date($Sender->EventArguments['Author']->DateFirstVisit).'';
        }
        }
    
    

    you want it to look like this in your file.

    if there is not a blank line between "class and closing ) of PluginInfo array it usually gives the error you experienced.

    you want it to look like this in your file.

    GOOD

    <?php if (!defined('APPLICATION')) exit();
    $PluginInfo['JoinDate'] = array(
        'Name' => 'JoinDate',
        'Version' => '1',
        'Author' => 'Bleistivt'
    );
    
    class JoinDatePlugin extends Gdn_Plugin {
    
        public function DiscussionController_CommentInfo_Handler($Sender) {
            $this->AddJoined($Sender);
        }
    
        public function DiscussionController_DiscussionInfo_Handler($Sender) {
            $this->AddJoined($Sender);
        }
    
        protected function AddJoined($Sender) {
            echo '<span class="MItem">' . T('Joined') . ': ' .
            Gdn_Format::Date($Sender->EventArguments['Author']->DateFirstVisit) . '</span>';
        }
    
    }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Hello,
    how can we also show dates like 01.01.1970
    Thanks

  • @vanillawhisky said:
    Hello,
    how can we also show dates like 01.01.1970
    Thanks

    Well I just found the solution,
    just change Gdn_Format::Date($Sender->EventArguments['Author']->DateFirstVisit) . '</span>'; to

    Gdn_Format::ToDateTime($Sender->EventArguments['Author']->DateFirstVisit) . '</span>'; if you want with time

    or just Gdn_Format::ToDate($Sender->EventArguments['Author']->DateFirstVisit) . '</span>'; if only date like
    2016-08-01
    . But still have one question,
    How can I change the date format (like german format 01.08.2016)?

  • @vanillawhisky said:
    how can we also show dates like 01.01.1970

    You would set that in your locale.php file via definitions I think...

    $Definition['Date.DefaultFormat'] = '%A %e %B, %Y';
    $Definition['Date.DefaultDayFormat'] = '%A %e %B %H:%M';
    $Definition['Date.DefaultYearFormat'] = '%A %e %B %Y';
    $Definition['Date.DefaultTimeFormat'] = '%A %l:%M%p';
    $Definition['Date.DefaultDateTimeFormat'] = '%A %e %B, %Y %l:%M%p %H:%M';
    
  • @vrijvlinder said:
    You would set that in your locale.php file via definitions I think...

    $Definition['Date.DefaultFormat'] = '%A %e %B, %Y';
    $Definition['Date.DefaultDayFormat'] = '%A %e %B %H:%M';
    $Definition['Date.DefaultYearFormat'] = '%A %e %B %Y';
    $Definition['Date.DefaultTimeFormat'] = '%A %l:%M%p';
    $Definition['Date.DefaultDateTimeFormat'] = '%A %e %B, %Y %l:%M%p %H:%M';
    

    Well , Thanks.
    I dont know know why but in my case , it didnt work.
    So I found other solution,
    I changed Gdn_Format::ToDate($Sender->EventArguments['Author']->DateFirstVisit) '; to

    Gdn_Format::Date($Sender->EventArguments['Author']->DateFirstVisit, '%d.%m.%Y');

    now you can get whatever format you need.

Sign In or Register to comment.