xoops forums

loukaum

Just popping in
Posted on: 2007/12/5 17:43
loukaum
loukaum (Show more)
Just popping in
Posts: 93
Since: 2003/11/2
#1

Add user to a specific group.

Hello All,

I got one group called "subscribed" and it´s groupid is 3.

I changed userinfo.php to show only to webmaster´s group a button on every user profile "Add to Subscribed Group" now I want to click on this button and put the users in this specific group.

How can I do that?

Thanks in advanced.
Resized Image

Bleekk

Theme Designer
Posted on: 2007/12/5 18:03
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 934
Since: 2002/12/14
#2

Re: Add user to a specific group.

why do you not add the user to the new group over system admin -> edit user -> modify user ?

loukaum

Just popping in
Posted on: 2007/12/5 18:10
loukaum
loukaum (Show more)
Just popping in
Posts: 93
Since: 2003/11/2
#3

Re: Add user to a specific group.

The person who will do this task can´t have the admin access (I will change the group allowed to access the button when finished this tweak), this person needs to get some users data before put the user at this group...
Resized Image

loukaum

Just popping in
Posted on: 2007/12/10 15:24
loukaum
loukaum (Show more)
Just popping in
Posts: 93
Since: 2003/11/2
#4

Re: Add user to a specific group.

any clue?
Resized Image

mboyden

Moderator
Posted on: 2007/12/10 19:36
mboyden
mboyden (Show more)
Moderator
Posts: 484
Since: 2005/3/9 1
#5

Re: Add user to a specific group.

Your best bet is to use a custom user/profile/registration module and give permissions to the right group to be able to administer the module (and thus do the group edits you want). The one I'd recommend at this point is SmartProfile (about all that currently exists).

Unfortunately, I've found there are still a few bugs in it, reported on the SmartProfile bugtracker at the devXoops site (site remains down at this point). First, get the CVS version 1.0.3 as posted in the forums, then to get it all updated to work right, you can get more info from a SmartFactory Posting or my posting.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

loukaum

Just popping in
Posted on: 2007/12/11 19:48
loukaum
loukaum (Show more)
Just popping in
Posts: 93
Since: 2003/11/2
#6

Re: Add user to a specific group.

Best regardings Mark!

First of all thanks for the link, I already use the Smartprofile and I need a lot the solutions that U developed! God blees U man! =D

Forgive my bad English, I try to do my best, but I know that isn´t enough. =D

Well let me explain about my environment on this site:

I got 5 groups who work on this site:

Webmasters
Anonymous
Registered
Subscribed
Selection Process
Financial

It´s for a Brazilian University, It´s an application form. Here in Brazil, to went to university U need to make a test with others students, the bests on the tests are able to study.

So, I have this form where people interested, can fill to do that test, so when he finish to fill the form and activate the account, he is on the Registered group. Ok! But only if he pay the "Subscribe Tax", he has the right to do the test, people ho has the right to do the test are in the Subscribed group.

Only the 2 members of the "Financial" group receive the report from the bank informing what users ID pay the tax. So they have to put that users in the "Subscribed" group to allow they to do the tests. But they also generate a report (made by hand) where they need some data from the custom fields. So, I setup the right permission in order to they see that fields.

What I want is: Hack SmartProfile, to allow The "Financial" group easily get that data (already working with smartprofile with right permisssions) and put the users on the "Subscribed" group. It´s almost everthing done, including the hacks on the SmartProfile to show the button "Mark as Subscribed" on the users profiles only to "Financial" group. But now, I don´t know what to put in that button to move the users from "registered" to "subscribed".

Basically, that´s it! :)
Resized Image

trabis

Core Developer
Posted on: 2007/12/11 20:15
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#7

Re: Add user to a specific group.

Precisas de direcionar o botão para um ficheiro que contenha estas linhas (entre outras claro)
$uid 120//deve conter o id do usuário que irá ser adicionado
$groupid 3//id do grupo ao qual vais adicionar.

$member_handler =& xoops_gethandler('member');
                            
// adicionar um usuário a um grupo
                            
if($groupid && $uid){

$result $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix('groups_users_link')." WHERE groupid='".$groupid."' AND uid=".$uid."");

list(
$group_check) = $xoopsDB->fetchRow($result);

$xoopsDB->freeRecordSet($result);

if(
$group_check == 0){

//Caso não esteja já adicionado então adicionar ao grupo

$member_handler->addUserToGroup($groupid$uid);

}
}


Atenção, eu não experimentei isto ainda mas deverá resultar.

loukaum

Just popping in
Posted on: 2007/12/11 21:03
loukaum
loukaum (Show more)
Just popping in
Posts: 93
Since: 2003/11/2
#8

Re: Add user to a specific group.

*** PROBLEM SOLVED ***

Trabis, muito obrigado pela ajuda! Saudações meu amigo.
Resized Image