phpBB

Development Wiki

Difference between revisions of "Function.group user add"

From phpBB Development Wiki

(Examples)
(Description)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
==Description==
 
==Description==
 +
This function is defined in includes/functions_user.php.
 
<pre>mixed  group_user_add  ( $group_id, [ $user_id_ary = false], [ $username_ary = false], [ $group_name = false], [ $default = false], [ $leader = 0], [ $pending = 0], [ $group_attributes = false])</pre>
 
<pre>mixed  group_user_add  ( $group_id, [ $user_id_ary = false], [ $username_ary = false], [ $group_name = false], [ $default = false], [ $leader = 0], [ $pending = 0], [ $group_attributes = false])</pre>
 
This function should be used to handle adding users to groups.
 
This function should be used to handle adding users to groups.
Line 31: Line 32:
  
 
==Return Values==
 
==Return Values==
Returns false if no errors ocurred, or the user language string for the relevant error. For example; 'NO_USER'.
+
Returns false if no errors ocurred, or the user language string for the relevant error. For example; 'NO_USER'.<br />
 +
Logs administrator actions for whatever changes were made.
  
 
==Examples==
 
==Examples==
Line 45: Line 47:
  
 
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 +
$user->add_lang('acp/groups');
 
</php>
 
</php>
 
<br />
 
<br />

Latest revision as of 01:02, 1 July 2012

Description

This function is defined in includes/functions_user.php.

mixed   group_user_add  ( $group_id, [ $user_id_ary = false], [ $username_ary = false], [ $group_name = false], [ $default = false], [ $leader = 0], [ $pending = 0], [ $group_attributes = false])

This function should be used to handle adding users to groups.

Parameters

Parameter Usage
group_id The user group id to add this user to.
user_id_arry User(s) id, does not have to be an array. If this is false, you must pass username_ary.
username_ary Usernames for users being added to group (optional).
group_name Name of group (optional).
default If true, will set this group as the default group for all users being added.
leader If true, all users will be a leader of the group.
pending If true, users will be set as pending and will not show in group list until approved.

Return Values

Returns false if no errors ocurred, or the user language string for the relevant error. For example; 'NO_USER'.
Logs administrator actions for whatever changes were made.

Examples

Example 1

Will add user to the Global Moderators group (group_id = 4). Will also make this group the users default.

<?php
group_user_add
(453falsefalsetrue);
?>


Example 2

To use in an ACP MOD, the following includes and declarations are required:

global $phpbb_root_path$phpEx;

include(
$phpbb_root_path 'includes/functions_user.' $phpEx);
$user->add_lang('acp/groups');


--Mtotheikle 03:13, 2 December 2008 (UTC)