Cron task

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
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: Cron task

Post by Hervé »

I didn't understood that answer
Hervé wrote: Mon Jul 15, 2024 7:53 am
thecoalman wrote: Sun Jul 14, 2024 5:38 pmOn line 406 of /includes/ucp/ucp_profile.php you would need to add conditional to alter the array $cp_data
I don't understand what you mean by "conditional to alter the array $cp_data".
Well this one
danieltj wrote: Tue Jul 16, 2024 5:57 pm
danieltj wrote: Tue Jul 16, 2024 4:46 pmUse the core.ucp_profile_info_modify_sql_ary event which is run just before the profile information is saved to the database. You can update the relevant profile field during that event before it's saved to the database.
Referenced in ucp_profile.php on line 400.
It’s documented above in the file. You should be able to read the code before the event and figure out what you need to do. To make it easier use var_dump to see the contents of the variables.
Anyway, it's resolved.
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: Cron task

Post by Hervé »

Perhaps one more information : why do I want to calculate the tank volume and not simply ask to members ?
Because there is a volume field but it is filled despite common sense, examples
dimensions ⇒ calculated volume / entered volume
90 x 90 x90 ⇒ 729 / 90
100x30x40 ⇒ 120 / 20
100x40x48 ⇒ 192 / 350
60x60x60 ⇒ 216 / 60
144x50x61 ⇒ 439 / 130
40x40x70 ⇒ 112 / 190
1520 x 555 x 960 ⇒ 810 / 250
60 157 42 ⇒ 396 / 150
70x70x98 ⇒ 480 / 190
120x60x60 ⇒ 432 / 666
73x57x66 ⇒ 275 / 130
120-30-160 ⇒ 576 / 275
1600 -500-500 ⇒ 400 / 600
70 50 50 ⇒ 175 / 91
48-48-50 ⇒ 115 / 60
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: Cron task

Post by Hervé »

Hervé wrote: Wed Jul 17, 2024 8:17 am This is the full added code, comments welcome
in /includes/ucp/ucp_profile.php after $vars = array('cp_data', 'data', 'sql_ary'); add

Code: Select all

$TankDim = preg_replace("/\D+/", ':',$cp_data['pf_tankdim']);	// Replace consecutive non-digits by ":" 
$Dim = array_pad(explode(":",$TankDim),3,"0");
$TankVol = round((int)$Dim[0]*(int)$Dim[1]*(int)$Dim[2]/1000);
($TankVol == 0) ? $TankVol = "?" : $TankVol = $TankVol." litres";	// (Condition) ? true : false
$cp_data["pf_autovol"] = $TankVol;
however the field "pf_autovol" remains empty,
I thought it would be automatically updated each time the member modifies "'pf_tankdim"
why not ?
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: Cron task

Post by Hervé »

Nobody knows why the field remains empty ?
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

Re: Cron task

Post by Hervé »

Clarification: the field is correctly calculated if the member modifies his profile, not when he enters it for the first time.
Perhaps I should also add my code into \includes\ucp\ucp_register.php
just before

Code: Select all

				// Register user...
				$user_id = user_add($user_row, $cp_data);

Return to “phpBB Custom Coding”