vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   User Profile Fields (https://vborg.vbsupport.ru/showthread.php?t=217392)

UltimateOreo! 06-29-2009 06:24 AM

User Profile Fields
 
Is it possible that a user profile field only be editable by select usergroups?

I don't want anybody other than these select groups to be able to edit this profile field.

Lynne 06-29-2009 01:53 PM

Not with the default vbulletin code, no. You would have to write some code to do that and I'm not really sure how complicated (or perhaps easy) it may be.

DragonBlade 06-29-2009 03:27 PM

Hey, buddy, you're in luck.

I recently made something so that our "GFX Crew" usergroup can "class" a user (which changes their "field25" value) in a form at the top of a thread within a specific forum. I'll post the code here and let you peruse it at your leisure.



Plugin 1: "Display Classing Form in Classification Forum"
Hook Location: "showthread_post_start"
Plugin Code:
PHP Code:

if ($thread['forumid'] == 156 AND is_member_of($vbulletin->userinfo6,44))
{
  
$classed_user fetch_userinfo($thread['postuserid']);
  eval(
'$poll .= "' fetch_template('gfx_classing_poll') . '";');


Brief Explaination: Just takes the Form that I made into a template and appends it to the "$poll" variable. It's a cheap and dirty hack, I guess, but it works. ;)

Note the "$forumid == 156" bit--that's because that's the only forum I wanted to allow them to do this in. :)

Note the "is_member_of()" bit. "6" is Admin, and "44" is the usergroup in question (our GFX Crew).



Plugin 2: "Class User and Move thread"
Hook Location: "showthread_start"
Plugin Code:
PHP Code:

if ($vbulletin->input->clean_gpc('p''gfx_class'TYPE_BOOL) AND ($forumid == 156) AND is_member_of($vbulletin->userinfo6,44))
{
  
$gfx_class =& $vbulletin->input->clean_gpc('p''field25'TYPE_STR);
  switch(
$gfx_class)
  {
    case 
'6'$iconid 0;  break;
    case 
'1'$iconid 18; break;
    case 
'2'$iconid 20; break;
    case 
'3'$iconid 19; break;
    case 
'4'$iconid 17; break;
    case 
'5'$iconid 21; break;
    default; eval(
print_standard_redirect('There has been an unspecified error.  Contact Sarteck.'falsetrue)); die; break;
  }

  
$gfx_userid =& $vbulletin->input->clean_gpc('p''gfx_userid'TYPE_INT);
  
$gfx_user fetch_userinfo($gfx_userid);
  if (!
$gfx_user) {eval(print_standard_redirect('There has been an unspecified error.  Contact Sarteck.'falsetrue)); die;}


  
// Class User
  
$userfield = array('field25' => $gfx_class);
  
$userman =& datamanager_init('User'$vbulletinERRTYPE_STANDARD);
  
$userman->set_existing($gfx_user);
  
$test $userman->set_userfields($userfieldfalse'admin');
  
$userman->save();

  
// Move Thread
  
require_once(DIR '/includes/functions_log_error.php');
  require_once(
DIR '/includes/functions_threadmanage.php');
  require_once(
DIR '/includes/functions_databuild.php');
  
$destforumid 157;
  
$destforuminfo fetch_foruminfo($destforumid);
  
$threadman =& datamanager_init('Thread'$vbulletinERRTYPE_STANDARD'threadpost');
  
$threadman->set_info('skip_moderator_log'true);
  
$threadman->set_existing($threadinfo);
  
$threadman->set('title'$threadinfo['title'], truefalse);
  
$threadman->set('forumid'$destforuminfo['forumid']);
  
$threadman->set('sticky'0);
  
$threadman->set('iconid'$iconid);
  
$threadman->save();
  
log_moderator_action($threadinfo'thread_moved_to_x'$destforuminfo['title']);
  
delete_post_cache_threads(array($threadinfo['threadid']));
  
build_forum_counters($threadinfo['forumid']);
  
build_forum_counters($destforuminfo['forumid']);

  
$phrase $gfx_user['musername'] . ' has been Classed.  Moving thread and redirecting to Classification forum.';
  
$vbulletin->url "forumdisplay.php?f=156" $vbulletin->session->vars['sessionurl'];
  eval(
print_standard_redirect($phrasefalsetrue));


Note the "$forumid == 156" bit--that's because that's the only forum I wanted to allow them to do this in. :)

Note the "is_member_of()" bit. "6" is Admin, and "44" is the usergroup in question (our GFX Crew).

Field 25 is the field in question on the userfield table.

The "switch($gfx_class)" bit was only for assigning a specific icon to the thread, and you'll likely not need to worry about it (i.e., you can get rid of it).

The bit under "// Class User" creates a User datamanager, and saves field25's new value. The bit under "// Move Thread" creates a Thread datamanager and moves the thread appropriately.

The rest just redirects. :)



If you've got questions, ask.



Oh, and here's the template I called for the form, if you wanted to take a gander...

HTML Code:

<!-- gfx_classing_poll :: GFX Classing system, written for Tess by Sarteck -->
<form method="post">
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="gfx_class" value="1" />
<input type="hidden" name="gfx_userid" value="$thread[postuserid]" />

<div class="tborder" style="padding: 4px;">
  <div style="width: 100%;">
    <div style="float: left; width: 50%; text-align: right;">
      <span style="font-variant: small-caps; margin-right: 20px;">Tess Classing System</span>
    </div>
    <div style="float: left; width: 25%;">
      <select name="field25" style="width: 90%; margin-left: auto; margin-right: auto; text-align: center;">
        <option value="6"<if condition="$classed_user['field25'] == 'Terribad!'"> selected="selected"</if>>Terribad!'</option>
        <option value="1"<if condition="$classed_user['field25'] == 'Beginner'"> selected="selected"</if>>Beginner</option>
        <option value="2"<if condition="$classed_user['field25'] == 'Amateur'"> selected="selected"</if>>Amateur</option>
        <option value="3"<if condition="$classed_user['field25'] == 'Experienced'"> selected="selected"</if>>Experienced</option>
        <option value="4"<if condition="$classed_user['field25'] == 'Advanced'"> selected="selected"</if>>Advanced</option>
        <option value="5"<if condition="$classed_user['field25'] == 'Professional'"> selected="selected"</if>>Professional</option>
      </select>
    </div>
    <div style="float: left; width: 25%;">
      <input type="submit" value="Class this user" style="width: 90%; margin-left: auto; margin-right: auto; text-align: center;" />
    </div>
    <div style="clear: both;"> </div>
  </div>
</div>

</form>




Yar, I think that was all of it.

(And no, I am not Tess, I wrote it for Tess. xP)

UltimateOreo! 06-29-2009 11:20 PM

You're a life-saver. Thanks a lot for the help.


All times are GMT. The time now is 08:53 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.01706 seconds
  • Memory Usage 1,768KB
  • 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_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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