vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   I added a new user field but I'm having trouble (https://vborg.vbsupport.ru/showthread.php?t=182211)

DISLEX 06-11-2008 07:05 PM

I added a new user field but I'm having trouble
 
Fixed this issue, new issue below

Opserty 06-11-2008 07:13 PM

Are you sure $vbulletin is availble at the hook?

You might need to use [minicode]$this->registry->userinfo['worksafemode'][/minicode]

DISLEX 06-11-2008 07:14 PM

that might be it, I figured $vbulletin was available everywhere though :)

Is $vbulletin just $this->registry?

MoT3rror 06-11-2008 07:57 PM

When vB uses a class they put $vbulletin as $this->registry so they don't have to global $vbulletin for each function.

DISLEX 06-11-2008 08:18 PM

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)

Opserty 06-11-2008 08:35 PM

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.

DISLEX 06-11-2008 08:38 PM

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?

Opserty 06-11-2008 08:59 PM

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

DISLEX 06-11-2008 09:55 PM

Quote:

Originally Posted by Opserty (Post 1547035)
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

okay so you're talking about "User Profile Field" in AdminCP? Doesn't that only affect fields in "Edit Profile" and not "Edit Options"? Because I don't see any of the fields added by previous products under that menu option.

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') {

  // MODE
  $profilefieldname = 'worksafemode';
  $mykey = 1;
  $myval = "Enable worksafe mode";

  $custom = "";
  $customfields['login'] .= "<fieldset class='fieldset'><legend>Worksafe Mode</legend>";
  $customfields['login'] .= '<table cellpadding="0" cellspacing="3" border="0" width="100%">
                                        <tr>
                                                <td>
                                                        Check this box if you wish to enable worksafe mode, which enables worksafe-related features<br />
                                                </td>
                                        </tr>
                                        <tr>';
       
  $mychecked= $vbulletin->userinfo['worksafemode'] ? 'checked="checked"' : '';
  $custom .= '<td valign="top"><label for="cb_cpf_'.$profilefieldname.'_'.$mykey.'"><input type="checkbox" name="userfield['.$profilefieldname.'][]" value="'.$mykey.'" id="cb_cpf_'.$profilefieldname.'_'.$mykey.'" '.$mychecked.' />'.$myval.'</label></td>';
       
  $customfields['login'] .= $custom;

  $customfields['login'] .= "</tr></table></fieldset>";
}

profile_updateoptions

Code:

$wsmode = intval($vbulletin->GPC['userfield']['worksafemode']);

$userdata->validfields['worksafemode'] = array(TYPE_NOCLEAN, REQ_NO);
$userdata->set('worksafemode' $wsmode, false);

I just tried to copy another plugin and this is the best I could come up with, hehe

Dismounted 06-12-2008 05:49 AM

Quote:

Originally Posted by DISLEX (Post 1547077)
okay so you're talking about "User Profile Field" in AdminCP? Doesn't that only affect fields in "Edit Profile" and not "Edit Options"? Because I don't see any of the fields added by previous products under that menu option.

You can choose where to put them. Fields will not show in the Admin CP if they were not added via the Admin CP method.


All times are GMT. The time now is 12:06 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
  • Page Generation 0.01169 seconds
  • Memory Usage 1,745KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete