Forum OpenACS Q&A: Group Membership in OpenACS4

Collapse
Posted by Hamilton Chua on
Hi,

On OpenACS3 - it was relatively easy to automatically make a user
who registers a member of a group. All I had to do was add a record
on the user to group map table and that's that.

On OpenACS4 however, things seem to have become rather complicated.
I have looked at the api-docs and found nothing that can help.

Any ideas,

Collapse
Posted by Dan Wickstrom on
It's also pretty easy in openacs4. Just use the pl/sql api to add the new user as a member of a group:

	db_exec_plsql new_member {
	    select membership_rel__new (null,
	                            'membership_rel',
	                            :group_id,
	                            :user_id,
	                            'approved',
	                            :creation_user,
	                            :creation_ip
                                    );
	}

Collapse
Posted by Hamilton Chua on
You are absolutely right - and in connection with this - I've found a lot of plsql functions in there that perform some stuff that I need.

I may have missed this but is there documentation on the pl-sql functions so that I can learn more about them ?

Thanks Again.

Collapse
Posted by Rod Cap on
Hi, I try this option but I don't realy know what to put in creation_user an creation_ip; I set it to null. But it doesn't relation the user into de group. Here is my source I modify from user-batch-add-2.tcl.  I apreciate responsing.
Thaks!
This is inside a while and group_id is a parameter.
I had to wrote sql "" because it throws an error.

set user_id [ad_user_new $email $first_names $last_name $password "" "" "" "t" "approved"]

    append success_text "Created user $user_id for ($row)<br\>"

    # Aqui se hace la relacion con el grupo
    db_exec_plsql sql "
        select membership_rel_new (null, 'membership_rel', :group_id, :user_id, 'approved',null,null)"

Collapse
Posted by Randy O'Meara on
Is there any reason not to use the tcl interface relation_add?