本文整理汇总了PHP中groups_promote_member函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_promote_member函数的具体用法?PHP groups_promote_member怎么用?PHP groups_promote_member使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_promote_member函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_groups_admin_load
//.........这里部分代码省略.........
if (!empty($_POST['bp-groups-role']) && !empty($_POST['bp-groups-existing-role'])) {
// Before processing anything, make sure you're not
// attempting to remove the all user admins
$admin_count = 0;
foreach ((array) $_POST['bp-groups-role'] as $new_role) {
if ('admin' == $new_role) {
$admin_count++;
break;
}
}
if (!$admin_count) {
$redirect_to = add_query_arg('no_admins', 1, $redirect_to);
$error = $group_id;
} else {
// Process only those users who have had their roles changed
foreach ((array) $_POST['bp-groups-role'] as $user_id => $new_role) {
$existing_role = isset($_POST['bp-groups-existing-role'][$user_id]) ? $_POST['bp-groups-existing-role'][$user_id] : '';
if ($existing_role != $new_role) {
switch ($new_role) {
case 'mod':
// Admin to mod is a demotion. Demote to
// member, then fall through
if ('admin' == $existing_role) {
groups_demote_member($user_id, $group_id);
}
case 'admin':
// If the user was banned, we must
// unban first
if ('banned' == $existing_role) {
groups_unban_member($user_id, $group_id);
}
// At this point, each existing_role
// is a member, so promote
$result = groups_promote_member($user_id, $group_id, $new_role);
break;
case 'member':
if ('admin' == $existing_role || 'mod' == $existing_role) {
$result = groups_demote_member($user_id, $group_id);
} elseif ('banned' == $existing_role) {
$result = groups_unban_member($user_id, $group_id);
}
break;
case 'banned':
$result = groups_ban_member($user_id, $group_id);
break;
case 'remove':
$result = groups_remove_member($user_id, $group_id);
break;
}
// Store the success or failure
if ($result) {
$success_modified[] = $user_id;
} else {
$error_modified[] = $user_id;
}
}
}
}
}
/**
* Fires before redirect so plugins can do something first on save action.
*
* @since 1.6.0
*
* @param int $group_id ID of the group being edited.
*/
示例2: groups_screen_group_admin_manage_members
/**
* This function handles actions related to member management on the group admin.
*/
function groups_screen_group_admin_manage_members()
{
if ('manage-members' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin()) {
return false;
}
$bp = buddypress();
if (bp_action_variable(1) && bp_action_variable(2) && bp_action_variable(3)) {
if (bp_is_action_variable('promote', 1) && (bp_is_action_variable('mod', 2) || bp_is_action_variable('admin', 2)) && is_numeric(bp_action_variable(3))) {
$user_id = bp_action_variable(3);
$status = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_promote_member')) {
return false;
}
// Promote a user.
if (!groups_promote_member($user_id, $bp->groups->current_group->id, $status)) {
bp_core_add_message(__('There was an error when promoting that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User promoted successfully', 'buddypress'));
}
/**
* Fires before the redirect after a group member has been promoted.
*
* @since 1.0.0
*
* @param int $user_id ID of the user being promoted.
* @param int $id ID of the group user is promoted within.
*/
do_action('groups_promoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
if (bp_action_variable(1) && bp_action_variable(2)) {
if (bp_is_action_variable('demote', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_demote_member')) {
return false;
}
// Stop sole admins from abandoning their group.
$group_admins = groups_get_group_admins($bp->groups->current_group->id);
if (1 == count($group_admins) && $group_admins[0]->user_id == $user_id) {
bp_core_add_message(__('This group must have at least one admin', 'buddypress'), 'error');
} elseif (!groups_demote_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when demoting that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User demoted successfully', 'buddypress'));
}
/**
* Fires before the redirect after a group member has been demoted.
*
* @since 1.0.0
*
* @param int $user_id ID of the user being demoted.
* @param int $id ID of the group user is demoted within.
*/
do_action('groups_demoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('ban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_ban_member')) {
return false;
}
// Ban a user.
if (!groups_ban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when banning that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User banned successfully', 'buddypress'));
}
/**
* Fires before the redirect after a group member has been banned.
*
* @since 1.0.0
*
* @param int $user_id ID of the user being banned.
* @param int $id ID of the group user is banned from.
*/
do_action('groups_banned_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('unban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_unban_member')) {
return false;
}
// Remove a ban for user.
if (!groups_unban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when unbanning that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User ban removed successfully', 'buddypress'));
}
//.........这里部分代码省略.........
示例3: test_groups_get_group_mods_cache
/**
* @group groups_get_group_mods
*/
public function test_groups_get_group_mods_cache()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$g = $this->factory->group->create(array('creator_id' => $u1));
// User 2 joins the group
groups_join_group($g, $u2);
// prime cache
groups_get_group_mods($g);
// promote user 2 to an admin
bp_update_is_item_admin(true);
groups_promote_member($u2, $g, 'mod');
// assert new cached value
$this->assertEquals(1, count(groups_get_group_mods($g)));
}
示例4: groups_screen_group_admin_manage_members
/**
* This function handles actions related to member management on the group admin.
*/
function groups_screen_group_admin_manage_members()
{
if ('manage-members' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin()) {
return false;
}
$bp = buddypress();
if (bp_action_variable(1) && bp_action_variable(2) && bp_action_variable(3)) {
if (bp_is_action_variable('promote', 1) && (bp_is_action_variable('mod', 2) || bp_is_action_variable('admin', 2)) && is_numeric(bp_action_variable(3))) {
$user_id = bp_action_variable(3);
$status = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_promote_member')) {
return false;
}
// Promote a user.
if (!groups_promote_member($user_id, $bp->groups->current_group->id, $status)) {
bp_core_add_message(__('There was an error when promoting that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User promoted successfully', 'buddypress'));
}
do_action('groups_promoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
if (bp_action_variable(1) && bp_action_variable(2)) {
if (bp_is_action_variable('demote', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_demote_member')) {
return false;
}
// Stop sole admins from abandoning their group
$group_admins = groups_get_group_admins($bp->groups->current_group->id);
if (1 == count($group_admins) && $group_admins[0]->user_id == $user_id) {
bp_core_add_message(__('This group must have at least one admin', 'buddypress'), 'error');
} elseif (!groups_demote_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when demoting that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User demoted successfully', 'buddypress'));
}
do_action('groups_demoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('ban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_ban_member')) {
return false;
}
// Ban a user.
if (!groups_ban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when banning that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User banned successfully', 'buddypress'));
}
do_action('groups_banned_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('unban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_unban_member')) {
return false;
}
// Remove a ban for user.
if (!groups_unban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when unbanning that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User ban removed successfully', 'buddypress'));
}
do_action('groups_unbanned_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('remove', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_remove_member')) {
return false;
}
// Remove a user.
if (!groups_remove_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error removing that user from the group. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User removed successfully', 'buddypress'));
}
do_action('groups_removed_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
do_action('groups_screen_group_admin_manage_members', $bp->groups->current_group->id);
bp_core_load_template(apply_filters('groups_template_group_admin_manage_members', 'groups/single/home'));
}
示例5: groups_screen_group_admin_manage_members
function groups_screen_group_admin_manage_members() {
global $bp;
if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
if ( !$bp->is_item_admin )
return false;
if ( 'promote' == $bp->action_variables[1] && ( 'mod' == $bp->action_variables[2] || 'admin' == $bp->action_variables[2] ) && is_numeric( $bp->action_variables[3] ) ) {
$user_id = $bp->action_variables[3];
$status = $bp->action_variables[2];
// Check the nonce first.
if ( !check_admin_referer( 'groups_promote_member' ) )
return false;
// Promote a user.
if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) )
bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
else
bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
}
if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
$user_id = $bp->action_variables[2];
// Check the nonce first.
if ( !check_admin_referer( 'groups_demote_member' ) )
return false;
// Demote a user.
if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
else
bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
}
if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
$user_id = $bp->action_variables[2];
// Check the nonce first.
if ( !check_admin_referer( 'groups_ban_member' ) )
return false;
// Ban a user.
if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' );
else
bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
}
if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
$user_id = $bp->action_variables[2];
// Check the nonce first.
if ( !check_admin_referer( 'groups_unban_member' ) )
return false;
// Remove a ban for user.
if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) )
bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
else
bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
}
if ( 'remove' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
$user_id = $bp->action_variables[2];
// Check the nonce first.
if ( !check_admin_referer( 'groups_remove_member' ) )
return false;
// Remove a user.
if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
bp_core_add_message( __( 'There was an error removing that user from the group, please try again', 'buddypress' ), 'error' );
else
bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
do_action( 'groups_removed_member', $user_id, $bp->groups->current_group->id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
}
do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
//.........这里部分代码省略.........
示例6: groups_screen_group_admin_manage_members
function groups_screen_group_admin_manage_members()
{
global $bp, $group_obj;
if ($bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0]) {
if (!$bp->is_item_admin) {
return false;
}
if ('promote' == $bp->action_variables[1] && is_numeric($bp->action_variables[2])) {
$user_id = $bp->action_variables[2];
// Promote a user.
if (!groups_promote_member($user_id, $group_obj->id)) {
bp_core_add_message(__('There was an error when promoting that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User promoted successfully', 'buddypress'));
}
do_action('groups_promoted_member', $user_id, $group_obj->id);
bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members');
}
if ('demote' == $bp->action_variables[1] && is_numeric($bp->action_variables[2])) {
$user_id = $bp->action_variables[2];
// Demote a user.
if (!groups_demote_member($user_id, $group_obj->id)) {
bp_core_add_message(__('There was an error when demoting that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User demoted successfully', 'buddypress'));
}
do_action('groups_demoted_member', $user_id, $group_obj->id);
bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members');
}
if ('ban' == $bp->action_variables[1] && is_numeric($bp->action_variables[2])) {
$user_id = $bp->action_variables[2];
// Ban a user.
if (!groups_ban_member($user_id, $group_obj->id)) {
bp_core_add_message(__('There was an error when banning that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User banned successfully', 'buddypress'));
}
do_action('groups_banned_member', $user_id, $group_obj->id);
bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members');
}
if ('unban' == $bp->action_variables[1] && is_numeric($bp->action_variables[2])) {
$user_id = $bp->action_variables[2];
// Remove a ban for user.
if (!groups_unban_member($user_id, $group_obj->id)) {
bp_core_add_message(__('There was an error when unbanning that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User ban removed successfully', 'buddypress'));
}
do_action('groups_unbanned_member', $user_id, $group_obj->id);
bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/manage-members');
}
do_action('groups_screen_group_admin_manage_members', $group_obj->id);
bp_core_load_template(apply_filters('groups_template_group_admin_manage_members', 'groups/admin/manage-members'));
}
}
示例7: thatcamp_add_member_to_group
/**
* A short version of groups_join_group(), without notification baggage
*
* @param int $user_id
* @param int $group_id
* @role string Desired group role. 'member', 'mod', or 'admin'
*/
function thatcamp_add_member_to_group($user_id, $group_id, $role)
{
$new_member = new BP_Groups_Member();
$new_member->group_id = $group_id;
$new_member->user_id = $user_id;
$new_member->inviter_id = 0;
$new_member->is_admin = 0;
$new_member->user_title = '';
$new_member->date_modified = bp_core_current_time();
$new_member->is_confirmed = 1;
$new_member->save();
groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
if ('admin' == $role || 'mod' == $role) {
groups_promote_member($user_id, $group_id, $role);
}
}
示例8: groups_screen_group_admin_manage_members
/**
* This function handles actions related to member management on the group admin.
*
* @package BuddyPress
*/
function groups_screen_group_admin_manage_members()
{
global $bp;
if (bp_is_groups_component() && bp_is_action_variable('manage-members', 0)) {
if (!$bp->is_item_admin) {
return false;
}
if (bp_action_variable(1) && bp_action_variable(2) && bp_action_variable(3)) {
if (bp_is_action_variable('promote', 1) && (bp_is_action_variable('mod', 2) || bp_is_action_variable('admin', 2)) && is_numeric(bp_action_variable(3))) {
$user_id = bp_action_variable(3);
$status = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_promote_member')) {
return false;
}
// Promote a user.
if (!groups_promote_member($user_id, $bp->groups->current_group->id, $status)) {
bp_core_add_message(__('There was an error when promoting that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User promoted successfully', 'buddypress'));
}
do_action('groups_promoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
if (bp_action_variable(1) && bp_action_variable(2)) {
if (bp_is_action_variable('demote', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_demote_member')) {
return false;
}
// Demote a user.
if (!groups_demote_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when demoting that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User demoted successfully', 'buddypress'));
}
do_action('groups_demoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('ban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_ban_member')) {
return false;
}
// Ban a user.
if (!groups_ban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when banning that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User banned successfully', 'buddypress'));
}
do_action('groups_banned_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('unban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_unban_member')) {
return false;
}
// Remove a ban for user.
if (!groups_unban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when unbanning that user, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User ban removed successfully', 'buddypress'));
}
do_action('groups_unbanned_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('remove', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_remove_member')) {
return false;
}
// Remove a user.
if (!groups_remove_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error removing that user from the group, please try again', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User removed successfully', 'buddypress'));
}
do_action('groups_removed_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
do_action('groups_screen_group_admin_manage_members', $bp->groups->current_group->id);
bp_core_load_template(apply_filters('groups_template_group_admin_manage_members', 'groups/single/home'));
}
}