![]() |
I added a new user field but I'm having trouble
Fixed this issue, new issue below
|
Are you sure $vbulletin is availble at the hook?
You might need to use [minicode]$this->registry->userinfo['worksafemode'][/minicode] |
that might be it, I figured $vbulletin was available everywhere though :)
Is $vbulletin just $this->registry? |
When vB uses a class they put $vbulletin as $this->registry so they don't have to global $vbulletin for each function.
|
can this cause an issue with cached values?
cause I'm still coding and messing with SQL queries to change the setting (since I don't have a front end to do it yet). And I just forced the field to 0, but it's still catching it and transforming to a URL (meaning it thinks $this->registry...etc is 1, not 0) |
Not sure what you are on about cache... but $this->registry is just a reference to $vbulletin so they hold the same values.
Use var_dump() to check the values of variables if you need to. |
Yeah I figured out the issue, nevermind. But now I have a new one..
I'm trying to add an option for this userfield (a checkbox) on the edit->options page. However I'm running into some strange issues. I'm not completely familiar with it, but I'm essentially copying another plugin. They have a hook on profile_complete, and then they throw in $customfields in there. I've done this, and made a checkbox which shows up, but I have two issues: 1) It's not updating the field correctly. I'm sifting through the PHP and also the templates, and I'm really confused how vB handles custom checkboxes. 2) All the other checkboxes default to unchecked when I have this hook enabled. I have NO idea why, as I'm only changing custom variables and nothing global. Any ideas? |
You have to extend the datamanager.
userfield refers to the Custom Profile Fields created in the AdminCP, you've manually altered the database so you need to alter the datamanager. Find other modifications which do the same and see if you can learn from them. Check the articles section for information about Datamanagers there are articles there. There is also information in the vBulletin manual. To be honest it would be easier to use the Custom Profile Fields in the AdminCP, then use fieldX in your code e.t.c |
Quote:
Also, this "data manager" you're referring to.. if I add a field to the User Profile Fields in Admin CP, is this altering the data manager like you're saying, or is that a different process? --------------- Added [DATE]1213226533[/DATE] at [TIME]1213226533[/TIME] --------------- This example code I'm looking, I just noticed it has another hook for profile_udateoptions, and it checks the variables and uses $userdata->set() to set the variables. I guess that's how it does it...? --------------- Added [DATE]1213228973[/DATE] at [TIME]1213228973[/TIME] --------------- Here is my code for profile_complete Code:
if($_REQUEST['do'] == 'editoptions') { Code:
$wsmode = intval($vbulletin->GPC['userfield']['worksafemode']); |
Quote:
|
Any ideas what's wrong with my code? Another plugin is essentially doing the same thing, but with text/select fields rather than a single checkbox...
I can't get the value to store when you click save, though. |
Just use "User Profile fields" vBulletin will then handle all the saving and editing and management of the front-end. It will save you a load of trouble.
You'd typically only be extending the user table if you are releasing a modification, to save modification users the trouble of creating the field. Otherwise it is far easier to stick to User Profile Fields. (The code you posted looks fine but I haven't messed about much with 3.7.x so I'm not sure how it is changed if at all.) |
Yeah, I'll probably end up doing it through the admin cp, but I also want to familiarize myself with vbulletin, so I'd really like to figure out what I did wrong in the code :)
|
It is always best to start out simple when you are learning.
For example just adding a code manually through the datamanger via. PHP then work onto submitting forms, using hooks, e.t.c. (instead of diving in at the deep end). |
I couldn't find a great tutorial or article on what I was trying to do - add a user field manually (instead of via Admin CP). The two datamanager articles I found didn't seem to really apply to me either. Can you help point me in the right direction?
|
<a href="http://www.vbulletin.com/docs/html/data_managers" target="_blank">Data Managers</a> (Check the "Advanced Datamanager Techniques" section it has something on modification via. Plugins)
|
All times are GMT. The time now is 01:36 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|