Forum OpenACS Q&A: Response to Group Membership in OpenACS4

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 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)"