Interface to manage users in a LiveUser group

The LiveUser_Admin package allows you to manage users within groups to be used within LiveUser. It provides a series of methods to interact with the «liveuser_groupusers» table.

The example 1 provided with this PEAR package should help you starting quite quickly.

There are a few methods for user groups management:

Prerequisite: you need to set the permission management level to, at least, «Medium» in the configuration file.

Download «conf_admin.php»

We'll start by adding a user to a group, then deleting the user from the group

Here is the full example :

Download «LUA_test_groupuser.php»

Add a User to a Group (addGroup)

function addUserToGroup($data)

Parameter(s)

This method takes 1 parameter:

  • an array with a pair key/value of all fields in the «liveuser_groupusers»

You must provide the group id and the user id at permission level (perm_user_id).

Return value

This method returns:

  • «false» in case of error
  • «true» otherwise

Example

To add a user to a group:

Code
   ...
    $data = array(
        'perm_user_id' => $users[0]['perm_user_id'],
        'group_id' => 5
       );
    $added = $LUA->perm->addUserToGroup($data);
   ...

This gives the following result:

Add a user to a group

Remove a User from a Group (removeUserFromGroup)

function removeUserFromGroup($filters)

Parameter(s)

This method takes 1 parameter:

  • an array with key/value to select the record(s) to be deleted.

Attention: if no parameter is passed, all group users will be removed.

Return value

This method returns:

  • «false» in case of error
  • «true» otherwise

Example

Code
   ...
    $filter = array(
        'perm_user_id' => $users[0]['perm_user_id'],
        'group_id' => $group_id
       );
    $removed = $LUA->perm->removeUserFromGroup($filter);
   ...

This gives the following result:

Remove a user from a group

Getting Information on the last Error (getErrors)

function getErrors()

In case a function returns «false», it means that it has encountered a problem. You can get information on this error by calling this method.

Parameter(s)

This method takes no parameter.

Return value

This method returns:

  • the error information

Example

Code
   ...
    $added = $LUA->perm->addUserToGroup($data);
    if ($added == false)
      {
      echo 'Add_groupuser: error on line: '.__LINE__;
      print_r($LUA->getErrors());
      }
    else
      {
      echo 'User with id ' . $data['perm_user_id'] . ' added to group id ' . $data['group_id'];
      }
   ...

Get in touch!

We'd love to hear from you, what you think about this page or what we can do for you.

Contact Us

View this page with IE8+, Mozilla Firefox, Safari, Chrome and Mobiles

Last modificaton on 21 May 2015 by St├ęphane Van Nerom

© 2006-2014 - GVN - All rights reserved
v2.0.14