Newb question on extensions

Discussion forum for Extension Writers regarding Extension Development.
edgeagg
Registered User
Posts: 11
Joined: Wed Sep 18, 2024 3:17 pm

Newb question on extensions

Post by edgeagg »

Hello all,
First of all forgive me if this question is stupid. I am a new user of phpbb. Haven't programmed php before but have done quite a lot of programming in other languages (golang/python/c/c++) etc.

1. I have made a numeric custom profile field that I want to increment once a month for all users. It seems that the right way to do this is to write an extension and use cron features to run it once a month. Is that right?
2. Obviously, I'd much prefer it if I could access the profile via a REST API - yes, I know phpbb doesn't have a REST API (yet) - though this would of course be absolutely awesome. Instead, it seems to me that instead of having the extension do this special purpose thing of incrementing a field, I could just make the extension be a REST proxy that proxies some of the paths in the phpbb3 api -> phpbb\profilefields\manager to validate and set some of the profile fields. That way, most of the business logic can be external to phpbb.

It is possible that there is yet another Third Way that I am unaware of. Can people enlighten me?
thanks
ea
User avatar
Anișor
Translator
Posts: 330
Joined: Tue Jan 08, 2013 9:36 pm
Location: Arbroath, Angus, Scotland

Re: Newb question on extensions

Post by Anișor »

What is the purpose of this?
Do you need that data to be stored in the database and then to use it somewhere? If you don’t want to store it and use it later you could probably use javascript to count and increment for each month from a given date instead.
User avatar
danieltj
Infrastructure Team Member
Infrastructure Team Member
Posts: 518
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Re: Newb question on extensions

Post by danieltj »

Your first point is the probably the best way right now. Create an extension where you can insert the ID field of the custom profile field and then use a cron system to automate the incremental change every however often you want to.

The best way would be through a REST API (which as you know, doesn't exist yet) with a cron job run on the server, a real cron as opposed to a fake cron down through phpBB.

Are you wanting to display something like total months / years that a user has been registered? As there are existing extensions that do something pretty similar. One being the Annual Stars extension.
💷 Purchase the Awesome Payments extension today!
Monetise your forum with one off payments and subscriptions.

Need a premium extension created? Send me a PM.

Return to “Extension Writers Discussion”