![]() |
AUTOJOIN - Auto-entry in membergroup via field in profile
Here's a little something to give back to this community that has been of such help to me.
With this plugin, you can have a user entered into or removed from a secondary usergroup according to several types of controls that can be placed in the user's profile via custom fields. This acts only on SECONDARY usergroups and will not affect the user's PRIMARY usergroup. At each login, the plugin will check for the appropriate setting in the user's profile, then add or remove the user from the specified membergroup as appropriate. Note that this does not act instantaneously upon entry of the data in the profile, but requires a new login for this to take effect. [Starting with vB 3.6.4 (maybe earlier, I didn't install anything between 3.5.4 and 3.6.4) this will take effect with one or two page reloads.] Controls currently available: 1) Password for single usergroupNote that you may write your own additional controls and use the two included functions to do the actual insertion into, and removal from, the target usergroups. Tested with vB 3.5.4, 3.6.4, 3.6.7-PL1, 3.8.7PL3 only. Full instructions are in the downloadable text file autojoin.txt. Update log:
|
[Post reserved fur future use. Control code that was previously here has been moved into the downloadable text file.]
|
1st to install and say thanks m8
|
I dont understand how this works sorry?
|
Quote:
This process is run each time the user logs in. Is that what you're asking? To make this work, you have to create a custom field in the profile where this password can be entered. You also need to create a custom $vbphrase that houses the required password value. |
Is it possible to enter them into the moderation of a private usergroup? I would love this but I need to know that the group leader can moderate these users
|
Quote:
This just adds the user to the usergroup, the same as if you checked the box for that forum after pulling up his record in the admincp. Whether this usergroup and/or forum require moderation is unaffected by this. |
can i use this to divorce the guys from the girls in my board??
|
What if you want to kick a specific user out of the usergroup and he knows the password to get back in?
|
Quote:
If that is a concern, I don't think this plugin will work for you. If usergroup membership is used only for forum access purposes, you can lock him out of certain forums via access masks. |
Quote:
A wouldn't think a password text field is the best way to do this. As long as you're going to be modifying code anyway, a radio button would make more sense. |
thanxxxxxxxxxxx
|
Code revised to version 1.02 - see first post in thread.
Rewritten using defined functions for adding to, and removing from, memberbgroups. This should make it easier to follow the logic and to make it easier for you to adapt the code for other situations (e.g. checkboxes or radio buttons instead of text profile fields). |
Quote:
So say for an example a clan called BobsArmy. Is it possible that BobsArmy can have a password, but once the user enters the password instead of being automatically joined into the BobsArmy usergroup he is added automatically to the application process which is found in the group membership page, allowing a second check by the group leader |
Quote:
Perhaps someone more familiar with that feature can give a more authoritative answer. But in that case, as long as it requires moderator intervention anyhow, how would this be an improvement over the standard application process? The whole idea here was to eliminate moderator involvement. |
Quote:
|
Understand i right, that for my problem i only modify this codes:
Code:
// Add or remove user from secondary usergroups |
Quote:
|
Quote:
BUT, I'm now trying to get this running on a test system, and there are some syntax errors that I'm working on correcting. (I warned you that this was untested code.) Please check back later. |
Quote:
Maybe you can wrote me a plugin, cause its to confusing for me what here is written, sorry. |
I've updated to version 1.03. When trying to adapt for situations other than the narrow password-in-custom-field control, some modifications were necessary, as the 1.02 code did not deal well with situations where no radio button choice had yet been made by the user.
[S]Code in first post reflects latest version 1.03.[/S] [S]See also the second post which has been updated with working code to use radio buttons in custom profile field to allow user to select one of several usergroups.[/S] All Code now included in download file. |
Quote:
|
Version 1.03.1 now in place. See first and second posts in thread.
|
Version 1.04 is now in place. It adds a check to prevent modifying the user's PRIMARY usergroup.
|
If i activate the plugin, then this error comes: Fatal error: Call to undefined function: outgroup() in /home/********l/public_html/forum/global.php(349) : eval()'d code on line 86
If i deactivate, everything looks good. Btw, the plugin doesnt work for me, maybe you can take a look on it: I have three fields, one for women (written in german/turkish) one for men, and one for "no i dont want to give this info", also in german/turkish. The only with a new usergroup is the first (groupid 20) |
Quote:
PHP Code:
Also note that you have a problem with the third option you entered. That should be Code:
// THIRD radio button option |
Ok, now it works, any hint to make it for the primary usergroup? Cause i want to move the primary usergroup, not the secondary ones.
|
All code has been removed from the first two posts in this thread. The latest versions of everything will always be located in the downloadable text file.
|
Quote:
If you want to change only the primary usergroup, your query needs to update usergroupid instead of membergroupids. Also, since there can only be one primary usergroup, it is a simpler operation because you just reset usergroupid to the new value and don't have to worry about leaving any other primary usergroups alone. This is untested, but it ought to be at least close to what you need: PHP Code:
|
screen shots?
|
Quote:
|
Quote:
So i must only use this one? or must i something replace from the old one? (the values i must change, that i have understand ;)) |
Quote:
|
thx, m8, installed it, now i must wait until my girls log in :D
|
Quote:
|
tried with a fake account, but it doesnt go. take a look at the code plz:
// Place user in/out of selected single PRIMARY // usergroup, according to selection made in profile, via // custom radio button field. ver 1.04 // ************** UNTESTED CODE **************** // Enter values in the strings below for your forum // custom field containing your radio button $radio_field = 'field5'; // FIRST radio button option // Text shown in radio button for option $choice_text[0] = 'Weiblich/Bayan'; // Associated usergroup number $ug[0] = '20'; // SECOND radio button option // Text shown in radio button for option $choice_text[1] = 'Männlich/Erkek'; // Associated usergroup number $ug[1] = '2'; // THIRD radio button option // Text shown in radio button for option $choice_text[2] = 'keine Angabe/Bilgi yok'; // Associated usergroup number $ug[2] = '2'; // add additional radio button choices as needed // You don't need to enter anything below here // Derive additional needed variables $userid = ($vbulletin->userinfo['userid']); $pgrp = $vbulletin->userinfo['usergroupid'])); $new_pgrp = $pgrp; $fieldval = $vbulletin->userinfo[$radio_field]; // Do the work // Proceed only if there is a user choice if ($fieldval != '') { if($ug[0] != '') { $iii = 0; // Check user choice against possible options foreach ($choice_text as $value) { // If we have a match, set as new primary usergroup if ($fieldval == $choice_text[$iii]) { $new_pgrp = $ug[$iii]; } $iii++; } } // if new group different than current group if ($new_gprp != $pgrp) { // Put updated usergroup into database $updatefields = $vbulletin->db->query(" UPDATE user SET usergroupid='$new_gprp' WHERE userid=$usrid "); } } |
Quote:
|
This seems like an awesome hack. So far however I have not been able to get it to work like what I need. After spending the entire day trying different variations I finally decided to ask the experts and post here.
I want members to be able to select one or more public groups to join. I first tried using a multiple-selection checkbox and after not being able to get that to work I setup 7 different single radio button fields and created a different single radio button plugin for each field. That did not work either. My question is --> Will this work with a multiple-selection checkbox? I want to create a multiple-selection checkbox and allow members to check off the groups they would like to be a member of. Those that are not checked off, I would like them to be removed from. Can this hack be used to accomplish this? Appreciate any help and/or assistance you can provide. Thank you. |
Quote:
|
Thank you very much. Looking forward to your custom control script for multiple-selection checkbox field.
|
All times are GMT. The time now is 06:42 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|