Membership duration in days?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
jackennils
Registered User
Posts: 178
Joined: Mon Jun 01, 2009 7:48 pm

Membership duration in days?

Post by jackennils » Sat Apr 28, 2018 11:54 am

Hello people!

Is there any way to display the number of days a user is registered on my forums in his profile/miniprofile?

Thanks!


Nils
Last edited by Mick on Sat Apr 28, 2018 2:19 pm, edited 1 time in total.
Reason: Moved from 3.2 support.

User avatar
david63
Jr. Extension Validator
Posts: 14654
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Membership duration in days?

Post by david63 » Sat Apr 28, 2018 12:03 pm

jackennils wrote:
Sat Apr 28, 2018 11:54 am
Is there any way to display the number of days a user is registered on my forums in his profile/miniprofile?
Not without an extension
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

jackennils
Registered User
Posts: 178
Joined: Mon Jun 01, 2009 7:48 pm

Re: Membership duration in days?

Post by jackennils » Sat Apr 28, 2018 12:05 pm

And is there an extension which can do that? Currently I'm using Auto Groups to put members in different groups according to the number of years they are registered. I want to display different information/icons in miniprofile/profile of my users based on how long they are registered.

So what I actually need is just something like: if user is in group id=x display ABC, if user is in group id=y display EDF
But unfortunately there's no functionality like "<!-- if postrow.USER_IN_GROUP_X --> ..... <!-- ENDIF -->"

User avatar
david63
Jr. Extension Validator
Posts: 14654
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Membership duration in days?

Post by david63 » Sat Apr 28, 2018 12:25 pm

jackennils wrote:
Sat Apr 28, 2018 12:05 pm
And is there an extension which can do that?
I cannot think of one, but somebody else may know of one.

However what you are now asking for now is a lot more complex than your initial request (which would be quite an easy extension to create).

I would suggest that you post your request in the Extension Requests forum.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

jackennils
Registered User
Posts: 178
Joined: Mon Jun 01, 2009 7:48 pm

Re: Membership duration in days?

Post by jackennils » Sat Apr 28, 2018 1:20 pm

Well, it can be done with just the number of days as well. The auto group part is not really needed.

<!-- if postrow.USER_REGISTERED_DAYS >= '365' and if postrow.USER_REGISTERED_DAYS < '730' --> display 1 year icon here <!-- ENDIF -->
<!-- if postrow.USER_REGISTERED_DAYS >= '730' and if postrow.USER_REGISTERED_DAYS < '1095' --> display 2 year icon here <!-- ENDIF -->

But yes, I'll do a request. Thanks anyway David!

User avatar
GanstaZ
Registered User
Posts: 422
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Membership duration in days?

Post by GanstaZ » Sat Apr 28, 2018 1:32 pm

This can be done with small listener:

Code: Select all

    public static function getSubscribedEvents()
    {
        return array(
            'core.memberlist_view_profile' => 'add_profile_stats',
        );
    }

    /**
    * Event core.memberlist_prepare_profile_data
    *
    * @param \phpbb\event\data $event The event object
    */
    public function add_profile_stats($event)
    {
        $member = $event['member']['user_regdate'];
        $memberdays = max(1, round((time() - $member) / 86400));

        $this->template->assign_vars(array(
            'l_member_days' => ($memberdays == 1) ? $this->language->lang('DAY') : $this->language->lang('DAYS'),
            'member_days'   => $memberdays,
        ));
    }
Of course language part can be moved to template event file.
"When answer lies in the question,.. question becomes redundant!"

User avatar
Mick
Support Team Member
Support Team Member
Posts: 20008
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Membership duration in days?

Post by Mick » Sat Apr 28, 2018 2:17 pm

Please note 3.2 support is not for coding discussion so I’ll move this appropriately. Also, if you need an extension you should post in the extensions forums.
"The more connected we get the more alone we become" - Kyle Broflovski

There are no ‘threads’ in phpBB, they are topics.

jackennils
Registered User
Posts: 178
Joined: Mon Jun 01, 2009 7:48 pm

Re: Membership duration in days?

Post by jackennils » Sat Apr 28, 2018 2:41 pm

GanstaZ wrote:
Sat Apr 28, 2018 1:32 pm
This can be done with small listener:

Code: Select all

    public static function getSubscribedEvents()
    {
        return array(
            'core.memberlist_view_profile' => 'add_profile_stats',
        );
    }

    /**
    * Event core.memberlist_prepare_profile_data
    *
    * @param \phpbb\event\data $event The event object
    */
    public function add_profile_stats($event)
    {
        $member = $event['member']['user_regdate'];
        $memberdays = max(1, round((time() - $member) / 86400));

        $this->template->assign_vars(array(
            'l_member_days' => ($memberdays == 1) ? $this->language->lang('DAY') : $this->language->lang('DAYS'),
            'member_days'   => $memberdays,
        ));
    }
Of course language part can be moved to template event file.
Thank you GangstaZ. Could you please explain how I use this?

User avatar
david63
Jr. Extension Validator
Posts: 14654
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Membership duration in days?

Post by david63 » Sat Apr 28, 2018 2:47 pm

jackennils wrote:
Sat Apr 28, 2018 2:41 pm
Could you please explain how I use this?
It will need to be paer of an extension which will require other files with it - such as template files.

@GanstaZ - that is not the correct way to use plurals in language files - see https://area51.phpbb.com/docs/dev/3.2.x ... urals.html
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

jackennils
Registered User
Posts: 178
Joined: Mon Jun 01, 2009 7:48 pm

Re: Membership duration in days?

Post by jackennils » Sat Apr 28, 2018 2:49 pm

Okay, so I will need an extension anyways. Alright, posting a request now in the extension request forum.

Done.

User avatar
AmigoJack
Registered User
Posts: 5324
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Membership duration in days?

Post by AmigoJack » Mon Apr 30, 2018 8:01 am

Keep in mind that this doesn't subtract days where an account was inactive or banned. So given how you define "duration" this may or may not a precise solution.
The worst thing about censorship is ███████████

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: Lumpy Burgertushie and 7 guests