View Full Version : If Profile Field Empty
TheInsaneManiac
12-12-2008, 12:32 AM
I want to make a script not run if a profile field is empty, but can't seem to find a conditional for this. I don't want this script to run if my profile field is not filled in:
if($vbulletin->options['xbl_avatar_system_enable_product'] AND $vbulletin->options['xbl_avatar_system_display_navbar'])
{
$xblavatarfield = $vbulletin->options['xbl_avatar_system_userfield'];
eval('$xblavatarhead = "<td style=\"padding:1px\"><a href=\"member.php?".$vbulletin->session->vars[sessionurl]."u=".$vbulletin->userinfo[userid]."\"><img src=\"http://avatar.xboxlive.com/avatar/".$vbulletin->userinfo[$xblavatarfield]."/avatarpic-l.png\" border=\"0\" /></a></td>";');
}
Dismounted
12-12-2008, 04:10 AM
You can access profile fields like this:
$vbulletin->userinfo['fieldX']
TheInsaneManiac
12-12-2008, 02:20 PM
So if($vbulletin->userinfo['field254']) would mean that if it is filled in it would run the script and if it wasn't it wouldn't run the script?
Gio~Logist
12-12-2008, 03:12 PM
if($vbulletin->userinfo['fieldx']){
// field x is filled
} else {
// field x is not filled
}
TheInsaneManiac
12-12-2008, 07:09 PM
if($vbulletin->userinfo['fieldx']){
// field x is filled
} else {
// field x is not filled
}
Thanx mate!
Gio~Logist
12-12-2008, 07:13 PM
:up:
Dismounted
12-13-2008, 03:38 AM
Let's apply some vBulletin coding standards there ;).
if ($vbulletin->userinfo['fieldx'])
{
// field x is filled
}
else
{
// field x is not filled
}
TheInsaneManiac
12-13-2008, 05:18 AM
Let's apply some vBulletin coding standards there ;).
if ($vbulletin->userinfo['fieldx'])
{
// field x is filled
}
else
{
// field x is not filled
}
I don't guess there is to prevent someone from using the same profile field as someone else is there?
Dismounted
12-13-2008, 08:40 AM
The field ID is the same for all users for a particular field. Each user is assigned their own row in the userfield table, which is fetched along with all the other user data.
TheInsaneManiac
12-14-2008, 05:32 AM
The field ID is the same for all users for a particular field. Each user is assigned their own row in the userfield table, which is fetched along with all the other user data.
So there is no way to detect if a field is the same as another?
Dismounted
12-14-2008, 09:39 AM
What part of a field? To see if what User A entered is the same as anyone else?
TheInsaneManiac
12-14-2008, 04:54 PM
What part of a field? To see if what User A entered is the same as anyone else?
Correct. I have a gamertag profile field and don't want anyone else choosing someone elses gamertag.
Dismounted
12-15-2008, 02:05 AM
You would have to do a query.
$tagcheck = $vbulletin->db->query_first("
SELECT fieldX
FROM " . TABLE_PREFIX . "userfield
WHERE fieldX = " . $vbulletin->userinfo['fieldx'] . "
LIMIT 1
");
if (empty($tagcheck))
{
// tag is not used by anyone
}
TheInsaneManiac
12-15-2008, 10:11 PM
Is it possible for it to do this when someone enters in a profile field?
Dismounted
12-16-2008, 03:03 AM
As in AJAX?
TheInsaneManiac
12-29-2008, 09:37 PM
no just check to see if someone has the same profile field as someone else after updating.
Dismounted
12-30-2008, 08:46 AM
There should be a hook where you can do a check before the data is commited to the database. Probably userdata_presave.
TheInsaneManiac
01-03-2009, 03:08 AM
There should be a hook where you can do a check before the data is commited to the database. Probably userdata_presave.
So I code a plugin with your script on the first page?
Dismounted
01-03-2009, 03:18 AM
Yep. Be sure to make note of the variables that exist (i.e. $this->registry instead of $vbulletin, etc.).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.