The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I'm looking to setup a simple On/Off Radio button in our profile fields. Based on whether that is set to on or off, I'd like to be able to display a certain bit of HTML on the forum home. Does anyone know how this can be done?
|
#2
|
|||
|
|||
![]()
First go to the User Profile Field menu in the adminCP and choose "Add New User Profile Field". When you've added your new radio button field, in the Profile Field Manager you can see what ID the new field was assigned, and then in a template you can check for the value. For instance if your new field is ID 8, then you'd check the value of $bbuserinfo[field8], like:
Code:
<if condition="$bbuserinfo[field8] == 'Yes'"> Yes <else /> No </if> But there's one other thing to note: when you add a field, all users will have a blank value for that field until they edit their profile and save it. So if you add a radio button with options Yes and No, you have to also handle the possibility of the value being blank. (You can do that by checking for the non-default value in your if condition. For instance, in the above example a blank field would act the same as 'No' because we checked for 'Yes'). |
#3
|
|||
|
|||
![]()
I suppose that I could set the default value of that field for all users via SQL. Not sure what the query would be for that, but it should be possible, no?
|
#4
|
|||
|
|||
![]()
You could do that. It should just be something like:
Code:
UPDATE userfield SET fieldX = 'Yes' WHERE fieldX = '' Where of course you'd use the field id place of X and put whatever default you want in place of 'Yes'. |
#5
|
|||
|
|||
![]()
That works brilliantly. Thanks a lot! I think I'll be making good use of that now that I know how it's done.
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|