The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Custom Profile Field - Add to 'Edit Email & Password' (modifypassword template)
Hi all,
How do I reference a Custom Profile Field in 'edit profile' type templates? I need to add a custom field to the 'modifypassword' template; in other templates (i.e. signature area in postbit) I have referenced them like this: PHP Code:
Kris... --------------- Added [DATE]1282311891[/DATE] at [TIME]1282311891[/TIME] --------------- The way I called custom profile fields in places like postbit templates is as indicated above. So, how would I call the same custom profile fields from somewhere like the 'modifypassword' template? Are custom profile fields actually in scope in these templates? And if not, how should I go about making them available (custom code in a hook!)? Any pointers on this would be very much appreciated, Kris... |
#2
|
||||
|
||||
Do a search in your files for 'modifypassword' (with the single quotes) and you should find where it is rendered and you will also find which variables are registered for use in that template. Unfortunately, there are no variables registered for use in that template (take a look at it and you'll only see phrases and $show which doesn't need to be registered). So, if you want to use some variables in there, you will have to preregister them for use.
|
#3
|
|||
|
|||
Thanks for the pointer Lynne,
OK, so I have created a plugin in the 'global_bootstrap_init_start' hook. This plugin contains the following 'test code' to preregister some dummy variables into the desired template. PHP Code:
PHP Code:
> How do I get the custom profile field values into my plugin? Do I have to run a database query? Or is there a smarter way? > Should I be using the 'global_bootstrap_init_start' hook; I got it to work with the 'profile_editpassword_start' hook too? > Should I use the 'global_bootstrap_init_start' hook and simply register all variables I'll need so I can implement them across multiple templates if needed? > Should I just be registering these values in the individual templates where needed? Thanks in advance for any pointers/advice, Kris... |
#4
|
||||
|
||||
Is this just the users/viewers fieldx? My guess is it may already have been queried and is available as variable $vbulletin->userinfo['fieldx'] . So, you could try using that.
You should only register a variable for use in the template you need to use it in. |
#5
|
|||
|
|||
Yes, you're right. The user profile fields for the logged in user are already queried and your example works.
I now have in my plugin in the 'global_bootstrap_init_start' hook. PHP Code:
And I can refer to each of these like so (in the 'modifypassword' template). PHP Code:
PHP Code:
With regards to the hook I amusing; should I use a more specific hook for 'modifypassword' template (if that was all I needed) so that it isnt invoked when not required? I was thinking of unnecessary overheads! Thanks for your help Lynne, you're a star, Kris... |
#6
|
||||
|
||||
If you turn on debug mode (add "$config['Misc']['debug'] = true;" to the config.php file), then you will see a list of all the hook locations called on the page in order. You can try those hook locations and see if there is a better, more local, one.
|
#7
|
|||
|
|||
Thanks again Lynne; I've found a couple of hooks that are much more local/specific for the template I am preRegistering my custom variables for.
Kris... |
#8
|
||||
|
||||
Just looking at this thread, how would I be able to utilize the array as a conditional? i.e. check that what it contains equals something?
I'm trying to get a check done on a ProfileField entry, and then if it exists, do display or remove part of the template. Any suggestions? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|