Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2007, 09:08 PM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Configuring a new field via usercp (user)

I'm having a bit of trouble.

I'm writing a mod where I'd like to alter a new field in the user table via the edit user page of the admincp.

I added the relevant phrases and then added this to the useradmin_edit_column2 hook:

Code:
print_table_break('', $INNERTABLEWIDTH);
print_table_header($vbphrase['ae_header']);
print_yes_no_row($vbphrase['ae_user_exempt_option'], 'user[mloginexempt]', $user['mloginexempt']);
This seems to work fine - it reads the value from the database, however the problem comes when I hit the "save" button. I get the following message:

Quote:
Fatal error: Field mloginexempt is not defined in $validfields in class vb_datamanager_user in /includes/class_dm.php on line 485
I've looked for somewhere to add this new variable, but so far I can't find it.

I tried adding this to useradmin_edit_start:

Code:
$user = array_merge($user, array('mloginexempt' => 0));
But this just had the effect of always reporting this option as "no", regardless of what the database said.

Does anyone know what the missing piece of code might be, and the hook where I should place it?

This could be useful for anyone else who tries to add an additional option to the edit user function of the admincp.

Mark
Reply With Quote
  #2  
Old 06-23-2007, 08:14 PM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone? This isn't really an obvious question, so was hoping someone with a bit more experience might be able to shed some light on this...
Reply With Quote
  #3  
Old 06-30-2007, 11:13 AM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Finally managed to solve this, and thought I'd share this here for anybody else who tries the same thing.

After several hours of sifting through tutorials, I found this one about adding bitfields.

I read through it and eventually figured out that I could adapt it to non-bitfield options. Therefore all I was missing was this code:

Code:
if (!isset($this->validfields['mloginexempt']))
{ 
    $this->validfields['mloginexempt'] = array(TYPE_BOOLEAN, REQ_NO);
}
Which I inserted at the userdata_data hook.

Yes, I know, I probably should have used a bitfield for this, but I'm just adding this on at the end. I'll know better for next time
Reply With Quote
  #4  
Old 06-30-2007, 02:51 PM
Michael Biddle Michael Biddle is offline
 
Join Date: Apr 2004
Location: Anaheim, CA
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In plugin: forumdata_start put this code in it to make a valid field.

$this->validfields['mloginexempt'] = array(TYPE_BOOLEAN, REQ_NO);
Reply With Quote
  #5  
Old 06-30-2007, 03:03 PM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by whitemike View Post
In plugin: forumdata_start put this code in it to make a valid field.

$this->validfields['mloginexempt'] = array(TYPE_BOOLEAN, REQ_NO);
Would I be doing that if I wanted to make use of it in all pages? At the moment I only need it when updating the record in the admincp. The other sections of the mod read the value directly from the DB (as part of a larger query).

Will changing it as you indicate also mean that it will work both in the admincp and could be read anywhere else?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:51 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03794 seconds
  • Memory Usage 2,197KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete