• Resolved poco06

    (@poco06)


    Hello,

    Thanks for your plugin. I’m trying to affect a user automatically to a specific group in a hook.
    I’ve found in the support forum this line to add :

    $current_user = wp_get_current_user();
    $user_id = $current_user->id;
    $group == 2; // 2 is the group ID I want to affect to the user
    Groups_User_Group::create(array( ‘user_id’ => $user_id, ‘group_id’ => $group->group_id ) );

    But when I run my hook, the user is not affected to the defined group
    I have also tried the following without success :

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

    Could you provide me with some help on this ?
    Many thanks
    Pat

    http://wordpress.org/plugins/groups/

Viewing 1 replies (of 1 total)
  • Thread Starter poco06

    (@poco06)

    Hello,

    Just to update my post as I found a solution :

    $current_user = wp_get_current_user();
    $user_id = $current_user->id;
    $groups = 2;
    Groups_User_Group::create(array( ‘user_id’ => $user_id, ‘group_id’ => $groups ) );

    Thanks
    Pat

Viewing 1 replies (of 1 total)

The topic ‘Issue Class 'Groups_User_Group' not working’ is closed to new replies.