vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   If Profile Field Empty (https://vborg.vbsupport.ru/showthread.php?t=198649)

TheInsaneManiac 12-12-2008 12:32 AM

If Profile Field Empty
 
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:
Code:

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:
PHP Code:

$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

PHP Code:

if($vbulletin->userinfo['fieldx']){

// field x is filled

} else {

// field x is not filled




TheInsaneManiac 12-12-2008 07:09 PM

Quote:

Originally Posted by Gio~Logist (Post 1683910)
PHP Code:

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 ;).
PHP Code:

if ($vbulletin->userinfo['fieldx'])
{
    
// field x is filled
}
else
{
    
// field x is not filled



TheInsaneManiac 12-13-2008 05:18 AM

Quote:

Originally Posted by Dismounted (Post 1684302)
Let's apply some vBulletin coding standards there ;).
PHP Code:

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

Quote:

Originally Posted by Dismounted (Post 1684395)
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

Quote:

Originally Posted by Dismounted (Post 1685091)
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.
PHP Code:

$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

Quote:

Originally Posted by Dismounted (Post 1697038)
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.).


All times are GMT. The time now is 07:40 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03312 seconds
  • Memory Usage 1,761KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete