UltimateOreo!
06-29-2009, 06:24 AM
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:if ($thread['forumid'] == 156 AND is_member_of($vbulletin->userinfo, 6,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:if ($vbulletin->input->clean_gpc('p', 'gfx_class', TYPE_BOOL) AND ($forumid == 156) AND is_member_of($vbulletin->userinfo, 6,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.', false, true)); 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.', false, true)); die;}
// Class User
$userfield = array('field25' => $gfx_class);
$userman =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userman->set_existing($gfx_user);
$test = $userman->set_userfields($userfield, false, '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', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
$threadman->set_info('skip_moderator_log', true);
$threadman->set_existing($threadinfo);
$threadman->set('title', $threadinfo['title'], true, false);
$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($phrase, false, true));
}
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...
<!-- 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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.