本文整理汇总了PHP中groups_new_group_forum_topic函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_new_group_forum_topic函数的具体用法?PHP groups_new_group_forum_topic怎么用?PHP groups_new_group_forum_topic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_new_group_forum_topic函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: bp_forums_directory_forums_setup
function bp_forums_directory_forums_setup() {
global $bp;
if ( $bp->current_component == $bp->forums->slug ) {
if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
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->root_domain );
}
$bp->is_directory = true;
do_action( 'bbpress_init' );
/* Check to see if the user has posted a new topic from the forums page. */
if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
/* Check the nonce */
check_admin_referer( 'bp_forums_new_topic' );
if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
/* Auto join this user if they are not yet a member of this group */
if ( !is_super_admin() && '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->groups->current_group->id );
if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
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' );
else
bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
} else {
bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
}
}
}
do_action( 'bp_forums_directory_forums_setup' );
bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
}
}
示例3: enable_forum_assignment_screen
/**
* enable_forum_assignment_screen( $vars )
*
* Hooks into screen_handler
* If forum is active for group, creates a thread for assignment
*
* @param Array $vars a set of variables received for this screen template
* @return Array $vars a set of variable passed to this screen template
*/
function enable_forum_assignment_screen($vars)
{
global $bp;
$e_forum_nonce = 'assignment_enable_forum';
$is_nonce = false;
if (isset($_POST['_wpnonce'])) {
$is_nonce = wp_verify_nonce($_POST['_wpnonce'], $e_forum_nonce);
}
// Nonce will take care of dublicates
if ($is_nonce && bp_group_is_forum_enabled()) {
$assignment = $this->is_assignment($this->current_assignment);
$assignment_forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
// Append assignment link to the content
$assignment->post_content = $assignment->post_content . "\n\n" . "<a href=\"" . $vars['current_uri'] . '/assignment/' . $assignment->post_name . "\">" . __('Courseware Assignment Link', 'bpsp') . "</a>";
// Create tags from title and append 'assignment' to it
$assignment->tags = str_replace('-', ', ', $assignment->post_name) . __(", assignment", 'bpsp');
// Create a topic for current assignment
$topic = groups_new_group_forum_topic($assignment->post_title, $assignment->post_content, $assignment->tags, $assignment_forum_id);
// Create topic for assignment and save in post_meta topic link
if ($topic) {
$topic_permalink = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug;
if (update_post_meta($assignment->ID, 'topic_link', $topic_permalink)) {
$vars['message'] = __('Assignment forum created.', 'bpsp');
}
// Force saving the new permalink to $vars, since it doesn't show up
$vars['forum_link'] = $topic_permalink;
}
} else {
$vars['error'] = __('Forum was not created.', 'bpsp');
}
return $this->single_assignment_screen($vars);
}
示例4: groups_screen_group_forum
//.........这里部分代码省略.........
// Fetch the post.
$post = bp_forums_get_post($post_id);
// Check the logged in user can edit this topic.
if (!bp_is_item_admin() && !bp_is_item_mod() && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
bp_core_redirect(wp_get_referer());
}
if (isset($_POST['save_changes'])) {
// Check the nonce.
check_admin_referer('bp_forums_edit_post');
$topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
if (!($post_id = groups_update_group_forum_post($post_id, $_POST['post_text'], $topic_id, $topic_page))) {
bp_core_add_message(__('There was an error when editing that post', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The post was edited successfully', 'buddypress'));
}
if ($_SERVER['QUERY_STRING']) {
$query_vars = '?' . $_SERVER['QUERY_STRING'];
}
/**
* Fires after the editing of a group forum post.
*
* @since 1.1.0
*
* @param int $post_id ID of the forum post being edited.
*/
do_action('groups_edit_forum_post', $post_id);
bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
}
/** This filter is documented in bp-groups/bp-groups-screens.php */
bp_core_load_template(apply_filters('groups_template_group_forum_topic_edit', 'groups/single/home'));
// Standard topic display.
} else {
if (!empty($user_is_banned)) {
bp_core_add_message(__("You have been banned from this group.", 'buddypress'));
}
/**
* Filters the template to load for a topic page.
*
* @since 1.1.0
*
* @param string $value Path to a topic template.
*/
bp_core_load_template(apply_filters('groups_template_group_forum_topic', 'groups/single/home'));
}
// Forum topic does not exist.
} elseif (!empty($topic_slug) && empty($topic_id)) {
bp_do_404();
return;
} else {
// Posting a topic.
if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
// Check the nonce.
check_admin_referer('bp_forums_new_topic');
if ($user_is_banned) {
$error_message = __("You have been banned from this group.", 'buddypress');
} elseif (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)) {
// Auto join this user if they are not yet a member of this group.
groups_join_group($bp->groups->current_group->id, bp_loggedin_user_id());
}
if (empty($_POST['topic_title'])) {
$error_message = __('Please provide a title for your forum topic.', 'buddypress');
} elseif (empty($_POST['topic_text'])) {
$error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
}
if (empty($forum_id)) {
$error_message = __('This group does not have a forum setup yet.', 'buddypress');
}
if (isset($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);
}
/**
* Fires at the end of the group forum screen loading process.
*
* @since 1.0.0
*
* @param int $topic_id ID of the topic being displayed.
* @param int $forum_id ID of the forum being displayed.
*/
do_action('groups_screen_group_forum', $topic_id, $forum_id);
/**
* Filters the template to load for a group forum page.
*
* @since 1.0.0
*
* @param string $value Path to a group forum template.
*/
bp_core_load_template(apply_filters('groups_template_group_forum', 'groups/single/home'));
}
}
示例5: groups_screen_group_forum
//.........这里部分代码省略.........
} else {
if (empty($user_is_banned) && bp_is_action_variable('delete', 2) && ($post_id = bp_action_variable(4))) {
// Fetch the post
$post = bp_forums_get_post($post_id);
// Check the logged in user can edit this topic
if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
bp_core_redirect(wp_get_referer());
}
// Check the nonce
check_admin_referer('bp_forums_delete_post');
do_action('groups_before_delete_forum_post', $post_id);
if (!groups_delete_group_forum_post($post_id)) {
bp_core_add_message(__('There was an error deleting that post', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The post was deleted successfully', 'buddypress'));
}
do_action('groups_delete_forum_post', $post_id);
bp_core_redirect(wp_get_referer());
} else {
if (empty($user_is_banned) && bp_is_action_variable('edit', 2) && ($post_id = bp_action_variable(4))) {
// Fetch the post
$post = bp_forums_get_post($post_id);
// Check the logged in user can edit this topic
if (!$bp->is_item_admin && !$bp->is_item_mod && (int) bp_loggedin_user_id() != (int) $post->poster_id) {
bp_core_redirect(wp_get_referer());
}
if (isset($_POST['save_changes'])) {
// Check the nonce
check_admin_referer('bp_forums_edit_post');
$topic_page = isset($_GET['topic_page']) ? $_GET['topic_page'] : false;
if (!($post_id = groups_update_group_forum_post($post_id, $_POST['post_text'], $topic_id, $topic_page))) {
bp_core_add_message(__('There was an error when editing that post', 'buddypress'), 'error');
} else {
bp_core_add_message(__('The post was edited successfully', 'buddypress'));
}
if ($_SERVER['QUERY_STRING']) {
$query_vars = '?' . $_SERVER['QUERY_STRING'];
}
do_action('groups_edit_forum_post', $post_id);
bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id);
}
bp_core_load_template(apply_filters('groups_template_group_forum_topic_edit', 'groups/single/home'));
} else {
if (!empty($user_is_banned)) {
bp_core_add_message(__("You have been banned from this group.", 'buddypress'));
}
bp_core_load_template(apply_filters('groups_template_group_forum_topic', 'groups/single/home'));
}
}
}
}
}
}
}
}
}
// Forum topic does not exist
} elseif (!empty($topic_slug) && empty($topic_id)) {
bp_do_404();
return;
} else {
// Posting a topic
if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
// Check the nonce
check_admin_referer('bp_forums_new_topic');
if ($user_is_banned) {
$error_message = __("You have been banned from this group.", 'buddypress');
} elseif (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)) {
// Auto join this user if they are not yet a member of this group
groups_join_group($bp->groups->current_group->id, bp_loggedin_user_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 (empty($forum_id)) {
$error_message = __('This group does not have a forum setup yet.', 'buddypress');
}
if (isset($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);
}
do_action('groups_screen_group_forum', $topic_id, $forum_id);
bp_core_load_template(apply_filters('groups_template_group_forum', 'groups/single/home'));
}
}
}
示例6: groups_screen_group_forum
//.........这里部分代码省略.........
/* Check the logged in user can edit 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() );
if ( isset( $_POST['save_changes'] ) ) {
/* Check the nonce */
check_admin_referer( 'bp_forums_edit_topic' );
if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) )
bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' );
else
bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );
do_action( 'groups_edit_forum_topic', $topic_id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' );
}
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
}
/* Delete a post */
else if ( 'delete' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
/* Fetch the post */
$post = bp_forums_get_post( $post_id );
/* Check the logged in user can edit this topic */
if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id )
bp_core_redirect( wp_get_referer() );
/* Check the nonce */
check_admin_referer( 'bp_forums_delete_post' );
if ( !groups_delete_group_forum_post( $bp->action_variables[4], $topic_id ) )
bp_core_add_message( __( 'There was an error deleting that post', 'buddypress'), 'error' );
else
bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') );
do_action( 'groups_delete_forum_post', $post_id );
bp_core_redirect( wp_get_referer() );
}
/* Editing a post */
else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
/* Fetch the post */
$post = bp_forums_get_post( $bp->action_variables[4] );
/* Check the logged in user can edit this topic */
if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id )
bp_core_redirect( wp_get_referer() );
if ( isset( $_POST['save_changes'] ) ) {
/* Check the nonce */
check_admin_referer( 'bp_forums_edit_post' );
if ( !$post_id = groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id, $_GET['topic_page'] ) )
bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
else
bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
if ( $_SERVER['QUERY_STRING'] )
$query_vars = '?' . $_SERVER['QUERY_STRING'];
do_action( 'groups_edit_forum_post', $post_id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );
}
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
}
/* Standard topic display */
else {
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/home' ) );
}
} else {
/* Posting a topic */
if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
/* Check the nonce */
check_admin_referer( 'bp_forums_new_topic' );
/* Auto join this user if they are not yet a member of this group */
if ( $bp->groups->auto_join && !is_super_admin() && '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 );
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' );
else
bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' );
}
do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/home' ) );
}
}
}
示例7: groups_screen_group_forum
function groups_screen_group_forum()
{
global $bp, $group_obj;
if ($bp->is_single_item) {
$topic_id = $bp->action_variables[1];
$forum_id = groups_get_groupmeta($group_obj->id, 'forum_id');
if ($topic_id) {
/* Posting a reply */
if (isset($_POST['submit_reply']) && function_exists('bp_forums_new_post')) {
groups_new_group_forum_post($_POST['reply_text'], $topic_id);
bp_core_redirect(bp_get_group_permalink($group_obj) . '/forum/topic/' . $topic_id);
}
do_action('groups_screen_group_forum_topic');
// If we are viewing a topic, load it.
bp_core_load_template(apply_filters('groups_template_group_forum', 'groups/forum/topic'));
} else {
/* Posting a topic */
if (isset($_POST['submit_topic']) && function_exists('bp_forums_new_topic')) {
groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id);
bp_core_redirect(bp_get_group_permalink($group_obj) . '/forum/');
}
do_action('groups_screen_group_forum', $topic_id, $forum_id);
// Load the forum home.
bp_core_load_template(apply_filters('groups_template_group_forum', 'groups/forum/index'));
}
}
}