本文整理汇总了PHP中bp_groups_auto_join函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_groups_auto_join函数的具体用法?PHP bp_groups_auto_join怎么用?PHP bp_groups_auto_join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_groups_auto_join函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groups_screen_group_forum
/**
* This screen function handles actions related to group forums.
*/
function groups_screen_group_forum()
{
if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
return false;
}
if (bp_action_variable(0) && !bp_is_action_variable('topic', 0)) {
bp_do_404();
return;
}
$bp = buddypress();
if (!$bp->groups->current_group->user_has_access) {
bp_core_no_access();
return;
}
if (!bp_is_single_item()) {
return false;
}
// Fetch the details we need.
$topic_slug = (string) bp_action_variable(1);
$topic_id = bp_forums_get_topic_id_from_slug($topic_slug);
$forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
$user_is_banned = false;
if (!bp_current_user_can('bp_moderate') && groups_is_user_banned(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
$user_is_banned = true;
}
if (!empty($topic_slug) && !empty($topic_id)) {
// Posting a reply.
if (!$user_is_banned && !bp_action_variable(2) && isset($_POST['submit_reply'])) {
// Check the nonce.
check_admin_referer('bp_forums_new_reply');
// Auto join this user if they are not yet a member of this group.
if (bp_groups_auto_join() && !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, bp_loggedin_user_id());
}
$topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
// Don't allow reply flooding.
if (bp_forums_reply_exists($_POST['reply_text'], $topic_id, bp_loggedin_user_id())) {
bp_core_add_message(__('It looks like you\'ve already said that!', 'buddypress'), 'error');
} else {
if (!($post_id = groups_new_group_forum_post($_POST['reply_text'], $topic_id, $topic_page))) {
bp_core_add_message(__('There was an error when replying to that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Your reply was posted successfully', 'buddypress'));
}
}
$query_vars = isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
$redirect = bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars;
if (!empty($post_id)) {
$redirect .= '#post-' . $post_id;
}
bp_core_redirect($redirect);
} elseif (bp_is_action_variable('stick', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
// Check the nonce.
check_admin_referer('bp_forums_stick_topic');
if (!bp_forums_sticky_topic(array('topic_id' => $topic_id))) {
bp_core_add_message(__('There was an error when making that topic a sticky', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was made sticky successfully', 'buddypress'));
}
/**
* Fires after a group forum topic has been stickied.
*
* @since 1.1.0
*
* @param int $topic_id ID of the topic being stickied.
*/
do_action('groups_stick_forum_topic', $topic_id);
bp_core_redirect(wp_get_referer());
} elseif (bp_is_action_variable('unstick', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
// Check the nonce.
check_admin_referer('bp_forums_unstick_topic');
if (!bp_forums_sticky_topic(array('topic_id' => $topic_id, 'mode' => 'unstick'))) {
bp_core_add_message(__('There was an error when unsticking that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was unstuck successfully', 'buddypress'));
}
/**
* Fires after a group forum topic has been un-stickied.
*
* @since 1.1.0
*
* @param int $topic_id ID of the topic being un-stickied.
*/
do_action('groups_unstick_forum_topic', $topic_id);
bp_core_redirect(wp_get_referer());
} elseif (bp_is_action_variable('close', 2) && (bp_is_item_admin() || bp_is_item_mod())) {
// Check the nonce.
check_admin_referer('bp_forums_close_topic');
if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
}
/**
* Fires after a group forum topic has been closed.
*
* @since 1.1.0
//.........这里部分代码省略.........
示例2: do_action
if (!bp_is_group_forum_topic_edit() && !bp_is_group_forum_topic()) {
?>
<?php
if (!bp_group_is_user_banned() && (is_user_logged_in() && 'public' == bp_get_group_status() || bp_group_is_member())) {
?>
<form action="" method="post" id="forum-topic-form" class="standard-form">
<div id="new-topic-post">
<?php
do_action('bp_before_group_forum_post_new');
?>
<?php
if (bp_groups_auto_join() && !bp_group_is_member()) {
?>
<p><?php
_e('You will auto join this group when you start a new topic.', 'buddypress');
?>
</p>
<?php
}
?>
<p id="post-new"></p>
<h4><?php
_e('Post a New Topic:', 'buddypress');
?>
</h4>
示例3: groups_screen_group_forum
/**
* This screen function handles actions related to group forums
*
* @package BuddyPress
*/
function groups_screen_group_forum()
{
global $bp;
if (!bp_is_active('forums') || !bp_forums_is_installed_correctly()) {
return false;
}
if (bp_action_variable(0) && !bp_is_action_variable('topic', 0)) {
bp_do_404();
return;
}
if (!$bp->groups->current_group->user_has_access) {
bp_core_no_access();
return;
}
if (bp_is_single_item()) {
// Fetch the details we need
$topic_slug = (string) bp_action_variable(1);
$topic_id = bp_forums_get_topic_id_from_slug($topic_slug);
$forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
$user_is_banned = false;
if (!bp_current_user_can('bp_moderate') && groups_is_user_banned(bp_loggedin_user_id(), $bp->groups->current_group->id)) {
$user_is_banned = true;
}
if (!empty($topic_slug) && !empty($topic_id)) {
// Posting a reply
if (!$user_is_banned && !bp_action_variable(2) && isset($_POST['submit_reply'])) {
// Check the nonce
check_admin_referer('bp_forums_new_reply');
// Auto join this user if they are not yet a member of this group
if (bp_groups_auto_join() && !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, bp_loggedin_user_id());
}
$topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
if (!($post_id = groups_new_group_forum_post($_POST['reply_text'], $topic_id, $topic_page))) {
bp_core_add_message(__('There was an error when replying to that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Your reply was posted successfully', 'buddypress'));
}
if (isset($_SERVER['QUERY_STRING'])) {
$query_vars = '?' . $_SERVER['QUERY_STRING'];
}
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
} else {
if (bp_is_action_variable('stick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
// Check the nonce
check_admin_referer('bp_forums_stick_topic');
if (!bp_forums_sticky_topic(array('topic_id' => $topic_id))) {
bp_core_add_message(__('There was an error when making that topic a sticky', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was made sticky successfully', 'buddypress'));
}
do_action('groups_stick_forum_topic', $topic_id);
bp_core_redirect(wp_get_referer());
} else {
if (bp_is_action_variable('unstick', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
// Check the nonce
check_admin_referer('bp_forums_unstick_topic');
if (!bp_forums_sticky_topic(array('topic_id' => $topic_id, 'mode' => 'unstick'))) {
bp_core_add_message(__('There was an error when unsticking that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was unstuck successfully', 'buddypress'));
}
do_action('groups_unstick_forum_topic', $topic_id);
bp_core_redirect(wp_get_referer());
} else {
if (bp_is_action_variable('close', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
// Check the nonce
check_admin_referer('bp_forums_close_topic');
if (!bp_forums_openclose_topic(array('topic_id' => $topic_id))) {
bp_core_add_message(__('There was an error when closing that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was closed successfully', 'buddypress'));
}
do_action('groups_close_forum_topic', $topic_id);
bp_core_redirect(wp_get_referer());
} else {
if (bp_is_action_variable('open', 2) && (isset($bp->is_item_admin) || isset($bp->is_item_mod))) {
// Check the nonce
check_admin_referer('bp_forums_open_topic');
if (!bp_forums_openclose_topic(array('topic_id' => $topic_id, 'mode' => 'open'))) {
bp_core_add_message(__('There was an error when opening that topic', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The topic was opened successfully', 'buddypress'));
}
do_action('groups_open_forum_topic', $topic_id);
bp_core_redirect(wp_get_referer());
} else {
if (empty($user_is_banned) && bp_is_action_variable('delete', 2) && !bp_action_variable(3)) {
// Fetch the topic
$topic = bp_forums_get_topic_details($topic_id);
/* Check the logged in user can delete this topic */
if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $topic->topic_poster) {
bp_core_redirect(wp_get_referer());
}
// Check the nonce
//.........这里部分代码省略.........