本文整理汇总了PHP中groups_get_current_group函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_get_current_group函数的具体用法?PHP groups_get_current_group怎么用?PHP groups_get_current_group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_get_current_group函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cfbgr_enqueue_current_user_has_access
/**
* Restrict access to a group regarding its 'member type'
*
* If a user is not logged in, he is redirected to the login form
* If a user ! member type, he is redirected to the groups directory
* If a user is a super admin, he can access
*
* @param bool $user_has_access
* @param array &$no_access_args the redirect args
* @return bool False if member type doesn't match, true otherwise
*/
function cfbgr_enqueue_current_user_has_access($user_has_access, &$no_access_args)
{
// If the user does not already have access bail
if (empty($user_has_access)) {
return $user_has_access;
}
// Get the member type of the group
$restriction = groups_get_groupmeta(bp_get_current_group_id(), 'cf-buddypress-group-restrictions');
// Don't touch to regular groups and leave Admins access
if (empty($restriction) || bp_current_user_can('bp_moderate')) {
return $user_has_access;
}
$current_group = groups_get_current_group();
if (!is_user_logged_in()) {
$user_has_access = false;
$no_access_args = array('message' => __('You must log in to access the page you requested.', 'buddypress-group-restrictions'), 'root' => bp_get_group_permalink($current_group) . 'home/', 'redirect' => false);
return $user_has_access;
// Current user does not match the restriction
} elseif ($restriction !== bp_get_member_type(bp_loggedin_user_id())) {
$user_has_access = false;
// Get infos about the member type
$member_type_object = bp_get_member_type_object($restriction);
$singular_name = '';
if (!empty($member_type_object->labels['singular_name'])) {
$singular_name = $member_type_object->labels['singular_name'];
}
// You need to redirect to a BuddyPress page to have
$no_access_args = array('mode' => 3, 'message' => sprintf(__('Sorry the group you tried to enter is only viewable for %s members', 'buddypress-group-restrictions'), esc_html($singular_name)), 'root' => bp_get_groups_directory_permalink(), 'redirect' => false);
return $user_has_access;
}
// By default, leave BuddyPress deal with access
return $user_has_access;
}
示例2: custom_media_nav_tab
/**
* Load Custom tabs on BuddyPress
*
* @global object $bp global BuddyPress object
*/
function custom_media_nav_tab()
{
global $bp;
if (!function_exists("bp_core_new_nav_item")) {
return;
}
if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) {
return;
}
global $rtmedia;
if (function_exists("bp_is_group") && !bp_is_group()) {
if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) {
$profile_counts = $this->actual_counts($bp->displayed_user->id);
}
$tab_position = apply_filters('rtmedia_media_tab_position', 99);
if ($rtmedia->options["buddypress_enableOnProfile"] != 0) {
bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position));
}
}
if (bp_is_group() && $rtmedia->options["buddypress_enableOnGroup"] != 0) {
global $bp;
$media_enabled = true;
//filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality
$media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled);
// check if current user can view this group
$current_group = groups_get_current_group();
$is_visible_to_current_user = $current_group->is_visible;
if ($media_enabled && $is_visible_to_current_user) {
$group_counts = $this->actual_counts($bp->groups->current_group->id, "group");
$bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . RTMEDIA_MEDIA_SLUG, 'slug' => RTMEDIA_MEDIA_SLUG, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all');
}
}
}
示例3: setup_item
/**
* Gets the item id of the item (eg group, user) associated with the page you're on.
*
* @package BuddyPress Docs
* @since 1.0-beta
*
* @return str $view The current item type
*/
function setup_item()
{
global $bp;
if (empty($this->item_type)) {
return false;
}
$id = '';
$name = '';
$slug = '';
switch ($this->item_type) {
case 'group':
if (bp_is_group()) {
$group = groups_get_current_group();
$id = $group->id;
$name = $group->name;
$slug = $group->slug;
}
break;
case 'user':
if (bp_is_user()) {
$id = bp_displayed_user_id();
$name = bp_get_displayed_user_fullname();
$slug = bp_get_displayed_user_username();
}
break;
}
// Todo: abstract into groups. Will be a pain
$this->item_id = apply_filters('bp_docs_get_item_id', $id);
$this->item_name = apply_filters('bp_docs_get_item_name', $name);
$this->item_slug = apply_filters('bp_docs_get_item_slug', $slug);
// Put some stuff in $bp
$bp->bp_docs->current_item = $this->item_id;
}
示例4: mp_group_nav
function mp_group_nav()
{
if (!bp_is_group()) {
return;
}
$component = 'groups';
$component_id = groups_get_current_group()->id;
if (mpp_user_can_create_gallery($component, $component_id)) {
echo sprintf("<li><a href='%s'>%s</a></li>", mpp_get_gallery_base_url($component, $component_id), __('All Galleries', 'mediapress'));
echo sprintf("<li><a href='%s'>%s</a></li>", mpp_get_gallery_create_url($component, $component_id), __('Create Gallery', 'mediapress'));
}
}
示例5: mpp_group_set_gallery_state
/**
* Set Gallery as enabled/disabled
*
* @param type $group_id
* @param type $enabled
* @return boolean
*/
function mpp_group_set_gallery_state($group_id = false, $enabled = 'yes')
{
if (!$group_id) {
$group_id = bp_get_group_id(groups_get_current_group());
}
if (!$group_id) {
return false;
}
//default settings from gloabl
$is_enabled = groups_update_groupmeta($group_id, '_mpp_is_enabled', $enabled);
return $is_enabled;
}
示例6: wff_populate_group_global
/**
* Populate the $groups_template global for use outside the loop
*
* We build the group navigation outside the groups loop. In order to use BP's
* group template functions while building the nav, we must have the template
* global populated. In this function, we fill in any missing data, based on
* the current group.
*
* This issue should be fixed more elegantly upstream in BuddyPress, ideally
* by making the template functions fall back on the current group when the
* loop global is not populated.
*/
function wff_populate_group_global()
{
global $groups_template;
if (bp_is_group() && isset($groups_template->groups[0]->group_id) && empty($groups_template->groups[0]->name)) {
$current_group = groups_get_current_group();
// Fill in all missing properties
foreach ($current_group as $cur_key => $cur_value) {
if (!isset($groups_template->groups[0]->{$cur_key})) {
$groups_template->groups[0]->{$cur_key} = $cur_value;
}
}
}
}
示例7: custom_media_nav_tab
/**
* Load Custom tabs on BuddyPress
*
* @global object $bp global BuddyPress object
*/
function custom_media_nav_tab()
{
$bp = buddypress();
if (!function_exists('bp_core_new_nav_item')) {
return;
}
if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) {
return;
}
global $rtmedia;
if (function_exists('bp_is_group') && !bp_is_group()) {
if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) {
$profile_counts = $this->actual_counts($bp->displayed_user->id);
}
$tab_position = apply_filters('rtmedia_media_tab_position', 99);
if (0 !== intval($rtmedia->options['buddypress_enableOnProfile'])) {
bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position));
}
}
if (bp_is_group() && 0 !== intval($rtmedia->options['buddypress_enableOnGroup'])) {
$media_enabled = true;
//filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality
$media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled);
// check if current user can view this group
$current_group = groups_get_current_group();
/**
* remove `$current_group->is_visible` and add `bp_group_is_visible( $current_group )`
* reason : In Buddypress 2.7 `is_visible` return false so we can't display `media` tab on group
* issue id : http://git.rtcamp.com/rtmedia/rtMedia/issues/119
*/
// $is_visible_to_current_user = $current_group->is_visible;
$is_visible_to_current_user = bp_group_is_visible($current_group);
if ($media_enabled && $is_visible_to_current_user) {
$group_counts = $this->actual_counts($bp->groups->current_group->id, 'group');
$slug = apply_filters('rtmedia_group_media_tab_slug', RTMEDIA_MEDIA_SLUG);
if (isset($bp->version) && $bp->version > '2.5.3') {
/*
* As from BuddyPress 2.6, you can't access $bp->bp_options_nav directly.
* Use `bp_core_new_subnav_item` to add subnav item.
*
* Check https://buddypress.trac.wordpress.org/ticket/6534 and https://buddypress.trac.wordpress.org/changeset/10745
* for more details
*/
bp_core_new_subnav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/'), 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all'));
} else {
$bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all');
}
}
}
}
示例8: buddydrive_get_group_buddydrive_url
/**
* Builds the BuddyDrive Group url
*
* @param integer $group_id the group id
* @uses groups_get_group to get group datas
* @uses groups_get_current_group() if no id was given to get current group datas
* @uses bp_get_group_permalink() to build the group permalink
* @uses buddydrive_get_slug() to get the BuddyDrive slug to end to the group url
* @return string $buddydrive_link the link to user's BuddyDrive
*/
function buddydrive_get_group_buddydrive_url($group_id = 0)
{
$buddydrive_link = false;
if (!empty($group_id)) {
$group = groups_get_group(array('group_id' => $group_id));
} else {
$group = groups_get_current_group();
}
if (!empty($group)) {
$group_link = bp_get_group_permalink($group);
$buddydrive_link = trailingslashit($group_link . buddydrive_get_slug());
}
return $buddydrive_link;
}
示例9: the_group
function the_group()
{
global $group;
$this->in_the_loop = true;
$this->group = $this->next_group();
if ($this->single_group) {
$this->group = groups_get_current_group();
} else {
if ($this->group) {
wp_cache_set('groups_group_nouserdata_' . $this->group->id, $this->group, 'bp');
}
}
if (0 == $this->current_group) {
// loop has just started
do_action('loop_start');
}
}
示例10: groups_record_activity
function groups_record_activity($args = '')
{
global $bp;
if (!bp_is_active('activity')) {
return false;
}
// Set the default for hide_sitewide by checking the status of the group
$hide_sitewide = false;
if (!empty($args['item_id'])) {
if (bp_get_current_group_id() == $args['item_id']) {
$group = groups_get_current_group();
} else {
$group = groups_get_group(array('group_id' => $args['item_id']));
}
if (isset($group->status) && 'public' != $group->status) {
$hide_sitewide = true;
}
}
$defaults = array('id' => false, 'user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => $bp->groups->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => $hide_sitewide);
$r = wp_parse_args($args, $defaults);
extract($r);
return bp_activity_add(array('id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide));
}
示例11: view_single
public function view_single()
{
$bp = buddypress();
if (function_exists('bp_is_group') && !bp_is_group()) {
return;
}
//do not catch the request for creating new post
if (bp_is_action_variable('create', 0)) {
return;
}
$current_group = groups_get_current_group();
if (bcg_is_disabled($current_group->id)) {
return;
}
//if the group is private/hidden and user is not member, return
if (($current_group->status == 'private' || $current_group->status == 'hidden') && (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $current_group->id))) {
return;
//avoid prioivacy troubles
}
if (bcg_is_component() && !empty($bp->action_variables[0])) {
//should we check for the existence of the post?
add_action('bp_template_content', array($this, 'get_single_post_contents'));
}
}
示例12: bp_get_groups_action_link
function bp_get_groups_action_link($action = '', $query_args = '', $nonce = false)
{
global $bp;
// Must be a group
if (empty($bp->groups->current_group->id)) {
return;
}
// Append $action to $url if provided
if (!empty($action)) {
$url = bp_get_group_permalink(groups_get_current_group()) . $action;
} else {
$url = bp_get_group_permalink(groups_get_current_group());
}
// Add a slash at the end of our user url
$url = trailingslashit($url);
// Add possible query arg
if (!empty($query_args) && is_array($query_args)) {
$url = add_query_arg($query_args, $url);
}
// To nonce, or not to nonce...
if (true === $nonce) {
$url = wp_nonce_url($url);
} elseif (is_string($nonce)) {
$url = wp_nonce_url($url, $nonce);
}
// Return the url, if there is one
if (!empty($url)) {
return $url;
}
}
示例13: show_settings
/**
* Show settings on single group page in front end
*
*/
public function show_settings()
{
$group_id = bp_get_current_group_id();
if ($this->current_user_can_modify_settings($group_id)) {
echo "<div class='group-page-link-box'>";
echo "<h4>" . __('Link to Page', 'link-page-to-groups') . "</h4>";
$this->admin_metabox(groups_get_current_group());
echo "</div>";
echo "<hr />";
}
}
示例14: rt_theme_compat_reset_post
function rt_theme_compat_reset_post($args = array())
{
global $wp_query, $post;
// Switch defaults if post is set
global $rtmedia_query;
if (isset($wp_query->post)) {
if (isset($rtmedia_query->query) && isset($rtmedia_query->query["media_type"]) && $rtmedia_query->query["media_type"] == "album" && isset($rtmedia_query->media_query["album_id"])) {
foreach ($rtmedia_query->album as $al) {
if ($al->id == $rtmedia_query->media_query["album_id"]) {
$wp_query->post = get_post($al->media_id);
break;
}
}
} else {
if (isset($rtmedia_query->media) && count($rtmedia_query->media) == 1 && $rtmedia_query->media) {
$wp_query->post = get_post($rtmedia_query->media[0]->media_id);
}
}
$dummy = wp_parse_args($args, array('ID' => $wp_query->post->ID, 'post_status' => $wp_query->post->post_status, 'post_author' => $wp_query->post->post_author, 'post_parent' => $wp_query->post->post_parent, 'post_type' => 'rtmedia', 'post_date' => $wp_query->post->post_date, 'post_date_gmt' => $wp_query->post->post_date_gmt, 'post_modified' => $wp_query->post->post_modified, 'post_modified_gmt' => $wp_query->post->post_modified_gmt, 'post_content' => $wp_query->post->post_content, 'post_title' => $wp_query->post->post_title, 'post_excerpt' => $wp_query->post->post_excerpt, 'post_content_filtered' => $wp_query->post->post_content_filtered, 'post_mime_type' => $wp_query->post->post_mime_type, 'post_password' => $wp_query->post->post_password, 'post_name' => $wp_query->post->post_name, 'guid' => $wp_query->post->guid, 'menu_order' => $wp_query->post->menu_order, 'pinged' => $wp_query->post->pinged, 'to_ping' => $wp_query->post->to_ping, 'ping_status' => $wp_query->post->ping_status, 'comment_status' => $wp_query->post->comment_status, 'comment_count' => $wp_query->post->comment_count, 'filter' => $wp_query->post->filter, 'is_404' => false, 'is_page' => false, 'is_single' => false, 'is_archive' => false, 'is_tax' => false));
} else {
$dummy = wp_parse_args($args, array('ID' => 0, 'post_status' => 'public', 'post_author' => 0, 'post_parent' => 0, 'post_type' => 'bp_member', 'post_date' => 0, 'post_date_gmt' => 0, 'post_modified' => 0, 'post_modified_gmt' => 0, 'post_content' => '', 'post_title' => '', 'post_excerpt' => '', 'post_content_filtered' => '', 'post_mime_type' => '', 'post_password' => '', 'post_name' => '', 'guid' => '', 'menu_order' => 0, 'pinged' => '', 'to_ping' => '', 'ping_status' => '', 'comment_status' => 'closed', 'comment_count' => 0, 'filter' => 'raw', 'is_404' => false, 'is_page' => false, 'is_single' => false, 'is_archive' => false, 'is_tax' => false));
}
if (function_exists("bp_is_group")) {
if (bp_is_group()) {
$dummy['post_type'] = "bp_group";
if ("bp-default" != get_option('stylesheet')) {
$dummy['post_title'] = '<a href="' . bp_get_group_permalink(groups_get_current_group()) . '">' . bp_get_current_group_name() . '</a>';
}
} else {
$dummy['post_type'] = "bp_member";
if ("bp-default" != get_option('stylesheet')) {
$dummy['post_title'] = '<a href="' . bp_get_displayed_user_link() . '">' . bp_get_displayed_user_fullname() . '</a>';
}
}
} else {
global $rtmedia_query;
$dummy['comment_status'] = 'closed';
if (isset($rtmedia_query->media_query)) {
if (isset($rtmedia_query->media_query["media_author"])) {
$dummy["post_author"] = $rtmedia_query->media_query["media_author"];
}
if (isset($rtmedia_query->media_query["id"])) {
//var_dump($rtmedia_query);
//echo $rtmedia_query->media_query["id"];
}
}
}
// Bail if dummy post is empty
if (empty($dummy)) {
return;
}
// Set the $post global
$post = new WP_Post((object) $dummy);
// Copy the new post global into the main $wp_query
$wp_query->post = $post;
$wp_query->posts = array($post);
// Prevent comments form from appearing
$wp_query->post_count = 1;
$wp_query->is_404 = $dummy['is_404'];
$wp_query->is_page = $dummy['is_page'];
$wp_query->is_single = $dummy['is_single'];
$wp_query->is_archive = $dummy['is_archive'];
$wp_query->is_tax = $dummy['is_tax'];
// Clean up the dummy post
unset($dummy);
/**
* Force the header back to 200 status if not a deliberate 404
*
* @see http://bbpress.trac.wordpress.org/ticket/1973
*/
if (!$wp_query->is_404()) {
status_header(200);
}
}
示例15: single_template_hierarchy
/**
* Add custom template hierarchy to theme compat for group pages.
*
* This is to mirror how WordPress has
* {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
*
* @since 1.8.0
*
* @param string $templates The templates from bp_get_theme_compat_templates().
* @return array $templates Array of custom templates to look for.
*/
public function single_template_hierarchy($templates)
{
// Setup some variables we're going to reference in our custom templates.
$group = groups_get_current_group();
/**
* Filters the Groups single pages template hierarchy based on priority.
*
* @since 1.8.0
*
* @param array $value Array of default template files to use.
*/
$new_templates = apply_filters('bp_template_hierarchy_groups_single_item', array('groups/single/index-id-' . sanitize_file_name(bp_get_current_group_id()) . '.php', 'groups/single/index-slug-' . sanitize_file_name(bp_get_current_group_slug()) . '.php', 'groups/single/index-action-' . sanitize_file_name(bp_current_action()) . '.php', 'groups/single/index-status-' . sanitize_file_name($group->status) . '.php', 'groups/single/index.php'));
// Merge new templates with existing stack.
// @see bp_get_theme_compat_templates().
$templates = array_merge((array) $new_templates, $templates);
return $templates;
}