Groups API question

Posted in

hello, sorry – wrong forum to post in but I can’t see where to post my question.

I am wanting to use Groups_User_Group::create for adding a user to a group. but can’t seem to get it to work.

For testing purposes I am using my test account with user id: ‘’ (I use email addresses as the login ID for accounts on my site)

and for testing purposes my group is called “SAGE” – Group id 2

I have set up the following:

$user_id=’’; ;

Groups_User_Group::create( array( ‘user_id’ => $user_id, ‘group_id’ => $group_id) );

However when I run it, it’s not adding the user to that group.

Am I missing a lot of other required configuration here, or is there just some mis-configuration?

I will, at some point enable a user to add themselves to multiple groups.

3 Responses to Groups API question

  1. Richard February 6, 2014 at 3:42 pm #


    You are a star!!! thank you so much. I wasn’t miles off, but you have got be back on track.

    So grateful 🙂


    • antonio February 7, 2014 at 7:03 am #

      perfect 😉

  2. antonio February 6, 2014 at 3:23 pm #

    “Groups_User_Group::create” needs user’s id. You can use for example:

    $user = get_user_by( 'email', '' );
    if ($user) {
    $result = Groups_User_Group::create( array( "user_id"=>$user->ID, "group_id"=>2 ) );


We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account