Firefox PHP

Template language query (losing profile fields in cc_usersettings.tpl)

Posted by sheik 
Template language query (losing profile fields in cc_usersettings.tpl)
July 24, 2009 05:30PM
I have a custom profile field called "subscriber", which if set to "1" I show extra fields in cc_usersettings.tpl
However, it never actually gets saved as "1", I change it in memory via a module, based on the value of another custom profile field, "subscription_expiry", which is a date.

So, via the "common" hook, I check "subscription_expiry" and if it is in the future, I update (in memory) $PHORUM["user"][subscriber"] to 1.

This works fine, and in the templates I can do calls like:

{IF PROFILE->subscriber}
  Thank you for supporting this site
{/IF}

etc etc

However, I've just noticed a problem when cc_usersetting.tpl is submitted. When I do this {PROFILE->subscriber} is not correctly set. In fact, if I add inline PHP, I can see that the whole of $PHORUM["user"] is empty.
I can repopulate it by adding global $PHORUM at the top of the file, but maybe that is not a good idea?
Even when I repopulate it though, I'm unsure how to force the templating language to know that {PROFILE->subscriber} is now set.
I know I can do inline PHP "if" statements, but this isn't very elegant, and I'd also like advice on whether making $PHORUM global is safe or not.

The real world problem I am trying to fix here, is that when a user saves their settings, it currently looks as if they have been unsubscribed - they'd have to reload the page in order to see that actually they haven't.

Thanks!

/\dam

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz




Edited 1 time(s). Last edit at 07/24/2009 05:31PM by sheik.
Re: Template language query (losing profile fields in cc_usersettings.tpl)
July 25, 2009 12:05PM
$PHORUM["user"] is *never* set in a template. Only $PHORUM['DATA'] and $PHORUM['TMP'] are copied for the templates. There is nothing special about this in the cc_usersettings.tpl

{PROFILE->subscriber} isn't available in all pages either so I'm not sure what you are doing there. Where are showing this? Probably not in the header.tpl.
Which panel exactly are you submitting where you get this behaviour? Did you try to check on {USER->subscriber} ?
AFAIK PROFILE is reset with the data retrieved for the user after saving. Your common hooks aren't rerun after resetting PROFILE.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Template language query (losing profile fields in cc_usersettings.tpl)
July 26, 2009 12:08AM
Hi Thomas,
{PROFILE->subscriber} is available in all my pages as I set it with a module using the common hook.

Quote

AFAIK PROFILE is reset with the data retrieved for the user after saving. Your common hooks aren't rerun after resetting PROFILE.

That would make sense then. Any idea which hook I can use that will get called after saving the user?
The screen is just the normal edit user screen, the one where you can set Real Name, and also update your location if running Maurice's Google Maps module.

/\dam

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Re: Template language query (losing profile fields in cc_usersettings.tpl)
July 26, 2009 01:27AM
There is no really appropriate hook I think. A hook in the user activate function could be useful for this, but currently there is no such hook. You could use the "start_output" hook to setup the template variable I think.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login