本文整理汇总了PHP中groups_is_user_admin函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_is_user_admin函数的具体用法?PHP groups_is_user_admin怎么用?PHP groups_is_user_admin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_is_user_admin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_gtm_get_access
function bp_gtm_get_access($user_id = false, $group_id = false, $action = false)
{
global $wpdb, $bp;
if (!$user_id) {
$user_id = $bp->loggedin_user->id;
}
if (!$bp->groups->current_group->id) {
return false;
}
if (!$group_id) {
$group_id = $bp->groups->current_group->id;
}
if (groups_is_user_admin($bp->loggedin_user->id, $bp->groups->current_group->id) || is_super_admin() || is_network_admin()) {
return true;
}
$sql = "SELECT `{$bp->gtm->table_roles}`. *\n FROM `{$bp->gtm->table_roles}`\n INNER JOIN `{$bp->gtm->table_roles_caps}` ON {$bp->gtm->table_roles_caps}.`role_id` = `{$bp->gtm->table_roles}`.`id`\n WHERE `{$bp->gtm->table_roles_caps}`.`user_id` = {$user_id}\n AND `{$bp->gtm->table_roles_caps}`.`group_id` = {$group_id}\n AND (\n `{$bp->gtm->table_roles}`.`group_id` = {$group_id}\n OR `{$bp->gtm->table_roles}`.`group_id` = '0'\n )\n LIMIT 1";
$result = $wpdb->get_results($wpdb->prepare($sql));
if (empty($result)) {
return false;
}
if ($result[0]->{$action} == 1) {
return true;
}
return false;
}
示例2: bcg_current_user_can_post
/**
* Can the current user post to group blog
* @global type $bp
* @return type
*/
function bcg_current_user_can_post()
{
$user_id = bp_loggedin_user_id();
$group_id = bp_get_current_group_id();
$can_post = is_user_logged_in() && (groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id));
return apply_filters('bcg_current_user_can_post', $can_post, $group_id, $user_id);
}
示例3: wpmudev_chat_is_moderator
/**
* Test whether logged in user is a moderator
*
* @param Array $moderator_roles Moderator roles
* @return bool $moderator True if moderator False if not
*/
function wpmudev_chat_is_moderator($chat_session, $debug = false)
{
global $current_user, $bp;
if ($chat_session['session_type'] === "bp-group") {
if (function_exists('groups_is_user_mod') && function_exists('groups_is_user_admin')) {
if (groups_is_user_mod($bp->loggedin_user->id, $bp->groups->current_group->id) || groups_is_user_admin($bp->loggedin_user->id, $bp->groups->current_group->id) || is_super_admin()) {
return true;
}
}
return false;
}
if ($chat_session['session_type'] === "private") {
global $wpmudev_chat;
if (!isset($chat_session['invite-info']['message']['host']['auth_hash'])) {
return false;
} else {
if (!isset($wpmudev_chat->chat_auth['auth_hash'])) {
return false;
} else {
if ($chat_session['invite-info']['message']['host']['auth_hash'] === $wpmudev_chat->chat_auth['auth_hash']) {
return true;
} else {
return false;
}
}
}
}
// all others
// If the chat session doesn't have any defined moderator roles then no need to go further.
if (!is_array($chat_session['moderator_roles']) || !count($chat_session['moderator_roles'])) {
return false;
}
if (!is_multisite()) {
if ($current_user->ID) {
foreach ($chat_session['moderator_roles'] as $role) {
if (in_array($role, $current_user->roles)) {
return true;
}
}
}
} else {
// We only consider super admins IF the normal 'administrator' role is set.
if (is_super_admin() && array_search('administrator', $chat_session['moderator_roles']) !== false) {
return true;
}
if ($current_user->ID) {
foreach ($chat_session['moderator_roles'] as $role) {
if (in_array($role, $current_user->roles)) {
return true;
}
}
}
}
return false;
}
示例4: bp_em_group_event_can_manage
/**
* @param boolean $result
* @param EM_Event $EM_Event
*/
function bp_em_group_event_can_manage($result, $EM_Event)
{
if (!$result && !empty($EM_Event->group_id) && bp_is_active('groups')) {
//only override if already false, incase it's true
if (groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) && current_user_can('edit_events')) {
//This user is an admin of the owner's group, so they can edit this event.
return true;
}
}
return $result;
}
示例5: __construct
/**
* Here you can see more customization of the config options
*/
function __construct()
{
global $buddyforms, $buddyforms_user_can;
$buddyforms_pig = get_option('buddyforms_pig_options');
$this->post_in_group_form_slug = groups_get_groupmeta(bp_get_current_group_id(), '_bf_pig_form_slug', true);
$this->buddyforms_pig = groups_get_groupmeta(bp_get_current_group_id(), '_buddyforms_pig', true);
$buddyforms_user_can = false;
//$this->enable_create_step = false;
$form_slug = $this->post_in_group_form_slug;
$name = $buddyforms[$form_slug]['name'];
if (isset($this->buddyforms_pig['create'])) {
switch ($this->buddyforms_pig['create']) {
case 'admin':
if (groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id())) {
$buddyforms_user_can = true;
}
break;
case 'mod':
if (groups_is_user_mod(bp_loggedin_user_id(), bp_get_current_group_id()) || groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id())) {
$buddyforms_user_can = true;
}
break;
case 'member':
default:
if (groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) {
$buddyforms_user_can = true;
}
break;
}
}
$args = array('slug' => $form_slug, 'name' => $name);
switch ($buddyforms_pig['permission']) {
case 'all':
add_action('bp_after_group_settings_admin', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
add_action('groups_group_settings_edited', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
add_action('bp_after_group_settings_creation_step', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
add_action('groups_create_group_step_save_group-settings', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
break;
case 'group-admin':
add_action('bp_after_group_settings_admin', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
add_action('groups_group_settings_edited', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
break;
case 'admin':
if (is_super_admin()) {
add_action('bp_after_group_settings_admin', array($this, 'bp_pig_after_group_manage_members_admin'), 1, 1);
add_action('groups_group_settings_edited', array($this, 'bf_pig_groups_group_settings_edited'), 10, 1);
}
break;
}
parent::init($args);
}
示例6: add_class_to_rtmedia_gallery
function add_class_to_rtmedia_gallery($classes)
{
global $rtmedia_query;
$user_id = get_current_user_id();
if (is_rt_admin() || isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile' && isset($rtmedia_query->query['context_id']) && $rtmedia_query->query['context_id'] == $user_id) {
$classes .= " rtm-pro-allow-action";
}
if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
$group_id = $rtmedia_query->query['context_id'];
if (groups_is_user_mod($user_id, $group_id) || groups_is_user_admin($user_id, $group_id)) {
$classes .= " rtm-pro-allow-action";
}
}
return $classes;
}
示例7: bp_em_group_event_can_manage
/**
* Overrides the default capability of the user for another owner's event if the user is a group admin and the event belongs to a group.
* User must have the relevant permissions globally in order to inherit that capability for this event as well.
* @param boolean $result
* @param EM_Event $EM_Event
*/
function bp_em_group_event_can_manage($result, $EM_Event, $owner_capability, $admin_capability, $user_to_check)
{
if (!$result && $EM_Event->event_owner != get_current_user_id() && !empty($EM_Event->group_id) && bp_is_active('groups')) {
//only override if already false, incase it's true
//if the user is an admin of this group, and actually has the relevant permissions globally, they can manage this event
$EM_Object = new EM_Object();
//create new object to prevent infinite loop should we call $EM_Event->can_manage();
if (groups_is_user_admin(get_current_user_id(), $EM_Event->group_id) && $EM_Object->can_manage($owner_capability, $admin_capability, $user_to_check)) {
//This user is an admin of the owner's group, so they can edit this event.
return true;
} else {
$EM_Event->add_error($EM_Object->get_errors());
//add any applicable errors
}
}
return $result;
}
示例8: before_render
function before_render()
{
if (!class_exists('BuddyPress') || !bp_is_active('groups')) {
return false;
}
$this->get();
// if group id is not set, don't render "Set featured"
if (empty($this->group_id)) {
return false;
}
$user_id = get_current_user_id();
// if current is not group moderator or group admin, don't render "Set featured"
if (!groups_is_user_mod($user_id, $this->group_id) && !groups_is_user_admin($user_id, $this->group_id) && !is_rt_admin()) {
return false;
}
// if current media is not any group media, don't render "Set featured"
if (!(isset($this->settings[$this->media->media_type]) && $this->settings[$this->media->media_type]) || isset($this->media->context) && 'group' != $this->media->context) {
return false;
}
if (isset($this->action_query) && isset($this->action_query->id) && $this->action_query->id == $this->featured) {
$this->label = $this->undo_label;
}
}
示例9: groups_ajax_invite_user
function groups_ajax_invite_user()
{
global $bp;
check_ajax_referer('groups_invite_uninvite_user');
if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
return false;
}
if (!groups_is_user_admin($bp->loggedin_user->id, $_POST['group_id'])) {
return false;
}
if (!friends_check_friendship($bp->loggedin_user->id, $_POST['friend_id'])) {
return false;
}
if ('invite' == $_POST['friend_action']) {
if (!groups_invite_user($_POST['friend_id'], $_POST['group_id'])) {
return false;
}
$user = new BP_Core_User($_POST['friend_id']);
echo '<li id="uid-' . $user->id . '">';
echo attribute_escape($user->avatar_thumb);
echo '<h4>' . attribute_escape($user->user_link) . '</h4>';
echo '<span class="activity">' . attribute_escape($user->last_active) . '</span>';
echo '<div class="action">
<a class="remove" href="' . wp_nonce_url($bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . attribute_escape($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
</div>';
echo '</li>';
} else {
if ('uninvite' == $_POST['friend_action']) {
if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) {
return false;
}
return true;
} else {
return false;
}
}
}
示例10: groups_notification_promoted_member
/**
* Notify group member they have been promoted.
*
* @since 1.0.0
*
* @param int $user_id ID of the user.
* @param int $group_id ID of the group.
* @return false|null False on failure.
*/
function groups_notification_promoted_member($user_id = 0, $group_id = 0)
{
// What type of promotion is this?
if (groups_is_user_admin($user_id, $group_id)) {
$promoted_to = __('an administrator', 'buddypress');
$type = 'member_promoted_to_admin';
} else {
$promoted_to = __('a moderator', 'buddypress');
$type = 'member_promoted_to_mod';
}
// Trigger a BuddyPress Notification.
if (bp_is_active('notifications')) {
bp_notifications_add_notification(array('user_id' => $user_id, 'item_id' => $group_id, 'component_name' => buddypress()->groups->id, 'component_action' => $type));
}
// Bail if admin opted out of receiving this email.
if ('no' === bp_get_user_meta($user_id, 'notification_groups_admin_promotion', true)) {
return false;
}
$group = groups_get_group(array('group_id' => $group_id));
$ud = bp_core_get_core_userdata($user_id);
$group_link = bp_get_group_permalink($group);
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
// Set up and send the message.
$to = $ud->user_email;
$subject = bp_get_email_subject(array('text' => sprintf(__('You have been promoted in the group: "%s"', 'buddypress'), $group->name)));
$message = sprintf(__('You have been promoted to %1$s for the group: "%2$s".
To view the group please visit: %3$s
---------------------
', 'buddypress'), $promoted_to, $group->name, $group_link);
// Only show the disable notifications line if the settings component is enabled.
if (bp_is_active('settings')) {
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
}
/**
* Filters the user email that the group promotion notification will be sent to.
*
* @since 1.2.0
*
* @param string $to User email the promotion notification is being sent to.
*/
$to = apply_filters('groups_notification_promoted_member_to', $to);
/**
* Filters the group promotion notification subject that will be sent to user.
*
* @since 1.2.0
*
* @param string $subject Promotion notification email subject text.
* @param BP_Groups_Group $group Object holding the current group instance. Passed by reference.
*/
$subject = apply_filters_ref_array('groups_notification_promoted_member_subject', array($subject, &$group));
/**
* Filters the group promotion notification message that will be sent to user.
*
* @since 1.2.0
*
* @param string $message Promotion notification email message text.
* @param BP_Groups_Group $group Object holding the current group instance. Passed by reference.
* @param string $promoted_to Role that the user was promoted to within the group.
* @param string $group_link URL permalink for the group that the promotion was related to.
* @param string $settings_link URL permalink for the user's notification settings area.
*/
$message = apply_filters_ref_array('groups_notification_promoted_member_message', array($message, &$group, $promoted_to, $group_link, $settings_link));
wp_mail($to, $subject, $message);
/**
* Fires after the notification is sent that a member has been promoted.
*
* @since 1.5.0
*
* @param int $user_id ID of the user who was promoted.
* @param string $subject Email notification subject text.
* @param string $message Email notification message text.
* @param int $group_id ID of the group that the user is a member of.
*/
do_action('bp_groups_sent_promoted_email', $user_id, $subject, $message, $group_id);
}
示例11: test_groups_is_user_admin_expected_false
public function test_groups_is_user_admin_expected_false()
{
$this->add_user_to_group(self::$user, self::$groups[0], array('is_admin' => false));
$this->add_user_to_group(self::$user, self::$groups[1], array('is_admin' => true));
$this->assertEquals(false, groups_is_user_admin(self::$user, self::$groups[0]));
}
示例12: friends_get_friends_invite_list
/**
* Get a list of friends that a user can invite into this group.
*
* Excludes friends that are already in the group, and banned friends if the
* user is not a group admin.
*
* @since BuddyPress (1.0.0)
*
* @param int $user_id User ID whose friends to see can be invited. Default:
* ID of the logged-in user.
* @param int $group_id Group to check possible invitations against.
* @return mixed False if no friends, array of users if friends.
*/
function friends_get_friends_invite_list($user_id = 0, $group_id = 0)
{
// Default to logged in user id
if (empty($user_id)) {
$user_id = bp_loggedin_user_id();
}
// Only group admins can invited previously banned users
$user_is_admin = (bool) groups_is_user_admin($user_id, $group_id);
// Assume no friends
$friends = array();
// Default args
$args = apply_filters('bp_friends_pre_get_invite_list', array('user_id' => $user_id, 'type' => 'alphabetical', 'per_page' => 0));
// User has friends
if (bp_has_members($args)) {
/**
* Loop through all friends and try to add them to the invitation list.
*
* Exclude friends that:
* 1. are already members of the group
* 2. are banned from this group if the current user is also not a
* group admin.
*/
while (bp_members()) {
// Load the member
bp_the_member();
// Get the user ID of the friend
$friend_user_id = bp_get_member_user_id();
// Skip friend if already in the group
if (groups_is_user_member($friend_user_id, $group_id)) {
continue;
}
// Skip friend if not group admin and user banned from group
if (false === $user_is_admin && groups_is_user_banned($friend_user_id, $group_id)) {
continue;
}
// Friend is safe, so add it to the array of possible friends
$friends[] = array('id' => $friend_user_id, 'full_name' => bp_get_member_name());
}
}
// If no friends, explicitly set to false
if (empty($friends)) {
$friends = false;
}
// Allow friends to be filtered
return apply_filters('bp_friends_get_invite_list', $friends, $user_id, $group_id);
}
示例13: map_meta_caps
/**
* Map rendez-vous caps for the group's context
*
* @package Rendez Vous
* @subpackage Groups
*
* @since Rendez Vous (1.1.0)
*
* @param array $caps Capabilities for meta capability
* @param string $cap Capability name
* @param int $user_id User id
* @param mixed $args Arguments
* @uses bp_is_group() to make sure the user is displaying a group
* @uses groups_get_current_group() to get the current group object
* @uses groups_is_user_member() to check if the user is a member of the group
* @uses groups_is_user_admin() to check if the user is an admin of the group
* @return array Actual capabilities for meta capability
*/
public function map_meta_caps($caps = array(), $cap = '', $user_id = 0, $args = array())
{
if (!bp_is_group() || empty($user_id)) {
return $caps;
}
$group = groups_get_current_group();
switch ($cap) {
case 'publish_rendez_vouss':
if (!empty($group->id) && groups_is_user_member($user_id, $group->id)) {
$caps = array('exist');
}
break;
case 'subscribe_rendez_vous':
if (groups_is_user_member($user_id, $group->id)) {
$caps = array('exist');
} else {
$caps = array('manage_options');
}
break;
// Group Admins have full powers
// Group Admins have full powers
case 'read_private_rendez_vouss':
case 'edit_rendez_vouss':
case 'edit_others_rendez_vouss':
case 'edit_rendez_vous':
case 'delete_rendez_vous':
case 'delete_rendez_vouss':
case 'delete_others_rendez_vouss':
if (!in_array('exist', $caps) && groups_is_user_admin($user_id, $group->id)) {
$caps = array('exist');
}
break;
}
return $caps;
}
示例14: can_user_create_album_in_group
/**
*
* @param type $group_id
* @param type $user_id
*
* @return boolean
*/
function can_user_create_album_in_group($group_id = false, $user_id = false)
{
if ($group_id == false) {
$group = groups_get_current_group();
$group_id = $group->id;
}
$upload_level = groups_get_groupmeta($group_id, "rt_media_group_control_level");
if (empty($upload_level)) {
$upload_level = groups_get_groupmeta($group_id, "bp_media_group_control_level");
if (empty($upload_level)) {
$upload_level = "all";
}
}
$user_id = get_current_user_id();
$display_flag = false;
if (groups_is_user_member($user_id, $group_id)) {
if ($upload_level == "admin") {
if (groups_is_user_admin($user_id, $group_id) > 0) {
$display_flag = true;
}
} else {
if ($upload_level == "moderators") {
if (groups_is_user_mod($user_id, $group_id) || groups_is_user_admin($user_id, $group_id)) {
$display_flag = true;
}
} else {
$display_flag = true;
}
}
}
$display_flag = apply_filters('can_user_create_album_in_group', $display_flag);
return $display_flag;
}
示例15: groups_notification_promoted_member
function groups_notification_promoted_member($user_id, $group_id)
{
if (groups_is_user_admin($user_id, $group_id)) {
$promoted_to = __('an administrator', 'buddypress');
$type = 'member_promoted_to_admin';
} else {
$promoted_to = __('a moderator', 'buddypress');
$type = 'member_promoted_to_mod';
}
// Post a screen notification first.
bp_core_add_notification($group_id, $user_id, 'groups', $type);
if ('no' == bp_get_user_meta($user_id, 'notification_groups_admin_promotion', true)) {
return false;
}
$group = groups_get_group(array('group_id' => $group_id));
$ud = bp_core_get_core_userdata($user_id);
$group_link = bp_get_group_permalink($group);
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
// Set up and send the message
$to = $ud->user_email;
$subject = bp_get_email_subject(array('text' => sprintf(__('You have been promoted in the group: "%s"', 'buddypress'), $group->name)));
$message = sprintf(__('You have been promoted to %1$s for the group: "%2$s".
To view the group please visit: %3$s
---------------------
', 'buddypress'), $promoted_to, $group->name, $group_link);
// Only show the disable notifications line if the settings component is enabled
if (bp_is_active('settings')) {
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
}
/* Send the message */
$to = apply_filters('groups_notification_promoted_member_to', $to);
$subject = apply_filters_ref_array('groups_notification_promoted_member_subject', array($subject, &$group));
$message = apply_filters_ref_array('groups_notification_promoted_member_message', array($message, &$group, $promoted_to, $group_link, $settings_link));
wp_mail($to, $subject, $message);
do_action('bp_groups_sent_promoted_email', $user_id, $subject, $message, $group_id);
}