• Resolved Mcwolf

    (@mcwolf00)


    Hi Alex,

    Sorry to bother u again.

    Just found another issue with new version:

    the old code is try to add an user in one group:

    global $userAccessManager;
    $uamAccessHandler = $userAccessManager->getAccessHandler();
    $uamUserGroup = $uamAccessHandler->getUserGroups("1");
    $uamUserGroup->addObject('user', $wp_uid); 
    $uamUserGroup->save();

    As upgrade to new version, i change:
    $uamUserGroup->addObject('user', $wp_uid);
    to
    $uamUserGroup->addObject('_user_', $wp_uid);

    But it still stops at this step with error:
    Fatal error: Call to a member function addObject() on array

    Can you help again? Thanks a lot.

    Cheers,
    Mcwolf

    • This topic was modified 9 years ago by Mcwolf.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author gm_alex

    (@gm_alex)

    getUserGroups doesn’t accept an argument anymore. To get the user group with id 1 use the following:

    $userGroups = $uamAccessHandler->getUserGroups();
    $userGroup = $userGroups[1];
    
    • This reply was modified 9 years ago by gm_alex.
    Thread Starter Mcwolf

    (@mcwolf00)

    Hi Alex,

    Thanks for your reply.

    Does that mean i cannot add user to userGroup by custom code with new version?

    If yes, is there any other workaround?

    Cheers,
    Dennis

    Thread Starter Mcwolf

    (@mcwolf00)

    Hi Alex,

    Sorry that cannot understand your suggestion at the first time.

    It is working now. Thanks.

    Cheers,
    Mcwolf

    Plugin Author gm_alex

    (@gm_alex)

    Great. I’m happy to hear that. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Call to a member function addObject() on array when use custom code to add user’ is closed to new replies.