当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_current_user_can函数代码示例

本文整理汇总了PHP中bp_current_user_can函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_current_user_can函数的具体用法?PHP bp_current_user_can怎么用?PHP bp_current_user_can使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_current_user_can函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: messages_action_conversation

/**
 * Process a request to view a single message thread.
 */
function messages_action_conversation()
{
    // Bail if not viewing a single conversation
    if (!bp_is_messages_component() || !bp_is_current_action('view')) {
        return false;
    }
    // Get the thread ID from the action variable
    $thread_id = (int) bp_action_variable(0);
    if (!messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !bp_current_user_can('bp_moderate')) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()));
    }
    // Check if a new reply has been submitted
    if (isset($_POST['send'])) {
        // Check the nonce
        check_admin_referer('messages_send_message', 'send_message_nonce');
        $new_reply = messages_new_message(array('thread_id' => $thread_id, 'subject' => !empty($_POST['subject']) ? $_POST['subject'] : false, 'content' => $_POST['content']));
        // Send the reply
        if (!empty($new_reply)) {
            bp_core_add_message(__('Your reply was sent successfully', 'buddypress'));
        } else {
            bp_core_add_message(__('There was a problem sending your reply. Please try again.', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/');
    }
    // Mark message read
    messages_mark_thread_read($thread_id);
    /**
     * Fires after processing a view request for a single message thread.
     *
     * @since BuddyPress (1.7.0)
     */
    do_action('messages_action_conversation');
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:36,代码来源:bp-messages-actions.php

示例2: test_should_return_false_if_site_admin_only_and_current_user_cannot_bp_moderate

 public function test_should_return_false_if_site_admin_only_and_current_user_cannot_bp_moderate()
 {
     // Should already be set to a 0 user.
     $this->assertFalse(bp_current_user_can('bp_moderate'));
     $args = array('name' => 'Foo', 'slug' => 'foo', 'site_admin_only' => true);
     $this->assertFalse(bp_core_new_nav_item($args));
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:7,代码来源:bpCoreNewNavItem.php

示例3: bp_register_default_taxonomies

/**
 * Register our default taxonomies.
 *
 * @since 2.2.0
 */
function bp_register_default_taxonomies()
{
    // Member Type.
    register_taxonomy(bp_get_member_type_tax_name(), 'user', array('public' => false));
    // Email type.
    register_taxonomy(bp_get_email_tax_type(), bp_get_email_post_type(), apply_filters('bp_register_email_tax_type', array('description' => _x('BuddyPress email types', 'email type taxonomy description', 'buddypress'), 'labels' => bp_get_email_tax_type_labels(), 'meta_box_cb' => 'bp_email_tax_type_metabox', 'public' => false, 'query_var' => false, 'rewrite' => false, 'show_in_menu' => false, 'show_tagcloud' => false, 'show_ui' => bp_is_root_blog() && bp_current_user_can('bp_moderate'))));
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:12,代码来源:bp-core-taxonomy.php

示例4: messages_action_view_message

function messages_action_view_message()
{
    global $thread_id, $bp;
    if (!bp_is_messages_component() || !bp_is_current_action('view')) {
        return false;
    }
    $thread_id = (int) bp_action_variable(0);
    if (!$thread_id || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !bp_current_user_can('bp_moderate')) {
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug());
    }
    // Check if a new reply has been submitted
    if (isset($_POST['send'])) {
        // Check the nonce
        check_admin_referer('messages_send_message', 'send_message_nonce');
        // Send the reply
        if (messages_new_message(array('thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content']))) {
            bp_core_add_message(__('Your reply was sent successfully', 'buddypress'));
        } else {
            bp_core_add_message(__('There was a problem sending your reply, please try again', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/');
    }
    // Mark message read
    messages_mark_thread_read($thread_id);
    // Decrease the unread count in the nav before it's rendered
    $name = sprintf(__('Messages <span>%s</span>', 'buddypress'), bp_get_total_unread_messages_count());
    $bp->bp_nav[$bp->messages->slug]['name'] = $name;
    do_action('messages_action_view_message');
    bp_core_new_subnav_item(array('name' => sprintf(__('From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id)), 'slug' => 'view', 'parent_url' => trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()), 'parent_slug' => bp_get_messages_slug(), 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_my_profile(), 'link' => bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id));
    bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home'));
}
开发者ID:newington,项目名称:buddypress,代码行数:31,代码来源:bp-messages-actions.php

示例5: messages_action_conversation

function messages_action_conversation()
{
    if (!bp_is_messages_component() || !bp_is_current_action('view')) {
        return false;
    }
    $thread_id = (int) bp_action_variable(0);
    if (!$thread_id || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !bp_current_user_can('bp_moderate')) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()));
    }
    // Check if a new reply has been submitted
    if (isset($_POST['send'])) {
        // Check the nonce
        check_admin_referer('messages_send_message', 'send_message_nonce');
        // Send the reply
        if (messages_new_message(array('thread_id' => $thread_id, 'subject' => !empty($_POST['subject']) ? $_POST['subject'] : false, 'content' => $_POST['content']))) {
            bp_core_add_message(__('Your reply was sent successfully', 'buddypress'));
        } else {
            bp_core_add_message(__('There was a problem sending your reply, please try again', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/');
    }
    // Mark message read
    messages_mark_thread_read($thread_id);
    do_action('messages_action_conversation');
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:25,代码来源:bp-messages-actions.php

示例6: xprofile_add_admin_menu

/**
 * Creates the administration interface menus and checks to see if the DB
 * tables are set up.
 *
 * @package BuddyPress XProfile
 * @uses bp_current_user_can() returns true if the current user is a site admin, false if not
 * @uses add_users_page() Adds a submenu tab to a top level tab in the admin area
 * @return
 */
function xprofile_add_admin_menu()
{
    if (!bp_current_user_can('bp_moderate')) {
        return false;
    }
    add_users_page(__('Profile Fields', 'buddypress'), __('Profile Fields', 'buddypress'), 'manage_options', 'bp-profile-setup', 'xprofile_admin');
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:16,代码来源:bp-xprofile-admin.php

示例7: bp_xprofile_map_meta_caps

/**
 * Maps XProfile caps to built in WordPress caps
 *
 * @since 1.6
 *
 * @param array $caps Capabilities for meta capability
 * @param string $cap Capability name
 * @param int $user_id User id
 * @param mixed $args Arguments
 * @uses get_post() To get the post
 * @uses get_post_type_object() To get the post type object
 * @uses apply_filters() Calls 'bp_map_meta_caps' with caps, cap, user id and
 *                        args
 * @return array Actual capabilities for meta capability
 */
function bp_xprofile_map_meta_caps($caps, $cap, $user_id, $args)
{
    switch ($cap) {
        case 'bp_xprofile_change_field_visibility':
            $caps = array('exist');
            // Must allow for logged-out users during registration
            // You may pass args manually: $field_id, $profile_user_id
            $field_id = isset($args[0]) ? (int) $args[0] : bp_get_the_profile_field_id();
            $profile_user_id = isset($args[1]) ? (int) $args[1] : bp_displayed_user_id();
            // Visibility on the fullname field is not editable
            if (1 == $field_id) {
                $caps[] = 'do_not_allow';
                break;
            }
            // Has the admin disabled visibility modification for this field?
            if ('disabled' == bp_xprofile_get_meta($field_id, 'field', 'allow_custom_visibility')) {
                $caps[] = 'do_not_allow';
                break;
            }
            // Friends don't let friends edit each other's visibility
            if ($profile_user_id != bp_displayed_user_id() && !bp_current_user_can('bp_moderate')) {
                $caps[] = 'do_not_allow';
                break;
            }
            break;
    }
    return apply_filters('bp_xprofile_map_meta_caps', $caps, $cap, $user_id, $args);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:43,代码来源:bp-xprofile-caps.php

示例8: bp_core_action_delete_user

/**
 * Process user deletion requests.
 *
 * Note: No longer called here. See the Settings component.
 */
function bp_core_action_delete_user()
{
    $userID = bp_displayed_user_id();
    echo "Buddypress:";
    echo $userID;
    $now = current_time('mysql');
    $args = array('date_query' => array('after' => '5 minute ago', 'before' => $now, 'inclusive' => true), 'post_id' => $postID, 'user_id' => $userID, 'count' => true);
    $userActivityCount = get_comments($args);
    if (!bp_current_user_can('bp_moderate') || bp_is_my_profile() || !bp_displayed_user_id() || $userActivityCount != 0) {
        return false;
    }
    if (bp_is_current_component('admin') && bp_is_current_action('delete-user') && $userActivityCount == 0) {
        // Check the nonce.
        check_admin_referer('delete-user');
        $errors = false;
        $style = "<style> #account-delete-form .submit{ display:none !important;} </style>";
        if ($userActivityCount != 0) {
            $errors = true;
            return $style;
        }
        do_action('bp_core_before_action_delete_user', $errors);
        if (bp_core_delete_account(bp_displayed_user_id()) || $userActivityCount == 0) {
            bp_core_add_message(sprintf(__('%s has been deleted from the system.', 'buddypress'), bp_get_displayed_user_fullname()));
        } else {
            bp_core_add_message(sprintf(__('There was an error deleting %s from the system. Please try again.', 'buddypress'), bp_get_displayed_user_fullname()), 'error');
            $errors = true;
        }
        do_action('bp_core_action_delete_user', $errors);
        if ($errors) {
            bp_core_redirect(bp_displayed_user_domain());
        } else {
            bp_core_redirect(bp_loggedin_user_domain());
        }
    }
}
开发者ID:ashpriom,项目名称:wp-auction,代码行数:40,代码来源:bp-members-actions.php

示例9: bp_forums_directory_forums_setup

/**
 * Load the Forums directory.
 */
function bp_forums_directory_forums_setup()
{
    // Get BuddyPress once
    $bp = buddypress();
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!bp_current_user_can('bp_moderate') && 'public' == $bp->groups->current_group->status && !groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:62,代码来源:bp-forums-screens.php

示例10: xprofile_add_admin_menu

/**
 * Creates the administration interface menus and checks to see if the DB
 * tables are set up.
 *
 * @uses bp_current_user_can() returns true if the current user is a site admin, false if not.
 * @uses add_users_page() Adds a submenu tab to a top level tab in the admin area.
 *
 * @return bool
 */
function xprofile_add_admin_menu()
{
    // Bail if current user cannot moderate community.
    if (!bp_current_user_can('bp_moderate')) {
        return false;
    }
    add_users_page(_x('Profile Fields', 'xProfile admin page title', 'buddypress'), _x('Profile Fields', 'Admin Users menu', 'buddypress'), 'manage_options', 'bp-profile-setup', 'xprofile_admin');
}
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:17,代码来源:bp-xprofile-admin.php

示例11: xprofile_add_admin_menu

/**
 * Creates the administration interface menus and checks to see if the DB
 * tables are set up.
 *
 * @package BuddyPress XProfile
 * @global object $bp Global BuddyPress settings object
 * @global $wpdb WordPress DB access object.
 * @uses bp_current_user_can() returns true if the current user is a site admin, false if not
 * @uses bp_xprofile_install() runs the installation of DB tables for the xprofile component
 * @uses wp_enqueue_script() Adds a JS file to the JS queue ready for output
 * @uses add_submenu_page() Adds a submenu tab to a top level tab in the admin area
 * @uses xprofile_install() Runs the DB table installation function
 * @return
 */
function xprofile_add_admin_menu()
{
    global $wpdb, $bp;
    if (!bp_current_user_can('bp_moderate')) {
        return false;
    }
    $hook = add_submenu_page('bp-general-settings', __('Profile Fields', 'buddypress'), __('Profile Fields', 'buddypress'), 'manage_options', 'bp-profile-setup', 'xprofile_admin');
    add_action("admin_print_styles-{$hook}", 'bp_core_add_admin_menu_styles');
}
开发者ID:newington,项目名称:buddypress,代码行数:23,代码来源:bp-xprofile-admin.php

示例12: bp_activity_add_admin_menu

/**
 * Registers the Activity component admin screen
 *
 * @since 1.6
 */
function bp_activity_add_admin_menu()
{
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    // Add our screen
    $hook = add_menu_page(__('Activity', 'buddypress'), __('Activity', 'buddypress'), 'manage_options', 'bp-activity', 'bp_activity_admin');
    // Hook into early actions to load custom CSS and our init handler.
    add_action("load-{$hook}", 'bp_activity_admin_load');
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:15,代码来源:bp-activity-admin.php

示例13: bp_forums_add_admin_menu

function bp_forums_add_admin_menu()
{
    global $bp;
    if (!bp_current_user_can('bp_moderate')) {
        return false;
    }
    // Add the administration tab under the "Site Admin" tab for site administrators
    $hook = add_submenu_page('bp-general-settings', __('Forums', 'buddypress'), __('Forums', 'buddypress'), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin");
    add_action("admin_print_styles-{$hook}", 'bp_core_add_admin_menu_styles');
}
开发者ID:newington,项目名称:buddypress,代码行数:10,代码来源:bp-forums-admin.php

示例14: bp_core_allow_default_theme

/**
 * bp_core_allow_default_theme()
 *
 * On multiblog installations you must first allow themes to be activated and show
 * up on the theme selection screen. This function will let the BuddyPress bundled
 * themes show up on the root blog selection screen and bypass this step. It also
 * means that the themes won't show for selection on other blogs.
 *
 * @package BuddyPress Core
 */
function bp_core_allow_default_theme($themes)
{
    global $wpdb;
    if (!bp_current_user_can('bp_moderate')) {
        return $themes;
    }
    if ($wpdb->blogid == bp_get_root_blog_id()) {
        $themes['bp-default'] = 1;
    }
    return $themes;
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:21,代码来源:bp-core-filters.php

示例15: bp_messages_enforce_current_user

/**
 * Enforce limitations on viewing private message contents
 *
 * @since BuddyPress (2.3.2)
 *
 * @see bp_has_message_threads() for description of parameters
 *
 * @param array|string $args See {@link bp_has_message_threads()}.
 */
function bp_messages_enforce_current_user($args = array())
{
    // Non-community moderators can only ever see their own messages
    if (is_user_logged_in() && !bp_current_user_can('bp_moderate')) {
        $_user_id = (int) bp_loggedin_user_id();
        if ($_user_id !== (int) $args['user_id']) {
            $args['user_id'] = $_user_id;
        }
    }
    // Return possibly modified $args array
    return $args;
}
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:21,代码来源:bp-messages-filters.php


注:本文中的bp_current_user_can函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。