本文整理汇总了PHP中groups_edit_group_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_edit_group_settings函数的具体用法?PHP groups_edit_group_settings怎么用?PHP groups_edit_group_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_edit_group_settings函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SavePost
public static function SavePost($post_id, $post, $update)
{
if (wp_is_post_revision($post_id) || $post->post_status != 'publish' || $post->post_type != 'namaste_course') {
return;
}
$meta = get_post_meta($post_id, 'buddypress_id', true);
if (empty($meta)) {
$group_id = groups_create_group(array('creator_id' => get_current_user_id(), 'name' => $post->post_title, 'description' => 'Обсуждение курса ' . $post->post_title, 'enable_forum' => 1));
update_post_meta($post_id, 'buddypress_id', $group_id);
groups_edit_group_settings($group_id, 1, 'private', 'mods');
$forum_id = bbp_insert_forum($forum_data = array('post_status' => bbp_get_private_status_id(), 'post_type' => bbp_get_forum_post_type(), 'post_author' => bbp_get_current_user_id(), 'post_content' => 'Обсуждение курса ' . $post->post_title, 'post_title' => $post->post_title), $forum_meta = array());
bbp_update_group_forum_ids($group_id, (array) $forum_id);
bbp_update_forum_group_ids($forum_id, (array) $group_id);
}
bbp_add_user_forum_subscription(bbp_get_current_user_id(), $forum_id);
update_post_meta($forum_id, '_forum_course_id', $post_id);
}
示例2: bp_groups_admin_load
//.........这里部分代码省略.........
// Group name and description are handled with
// groups_edit_base_group_details()
if (!groups_edit_base_group_details($group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0)) {
$error = $group_id;
// using negative integers for different error messages... eek!
if (empty($_POST['bp-groups-name']) && empty($_POST['bp-groups-description'])) {
$error = -3;
} elseif (empty($_POST['bp-groups-name'])) {
$error = -1;
} elseif (empty($_POST['bp-groups-description'])) {
$error = -2;
}
}
// Enable discussion forum
$enable_forum = isset($_POST['group-show-forum']) ? 1 : 0;
/**
* Filters the allowed status values for the group.
*
* @since 1.0.2
*
* @param array $value Array of allowed group statuses.
*/
$allowed_status = apply_filters('groups_allowed_status', array('public', 'private', 'hidden'));
$status = in_array($_POST['group-status'], (array) $allowed_status) ? $_POST['group-status'] : 'public';
/**
* Filters the allowed invite status values for the group.
*
* @since 1.5.0
*
* @param array $value Array of allowed invite statuses.
*/
$allowed_invite_status = apply_filters('groups_allowed_invite_status', array('members', 'mods', 'admins'));
$invite_status = in_array($_POST['group-invite-status'], (array) $allowed_invite_status) ? $_POST['group-invite-status'] : 'members';
if (!groups_edit_group_settings($group_id, $enable_forum, $status, $invite_status)) {
$error = $group_id;
}
// Process new members
$user_names = array();
if (!empty($_POST['bp-groups-new-members'])) {
$user_names = array_merge($user_names, explode(',', $_POST['bp-groups-new-members']));
}
if (!empty($user_names)) {
foreach (array_values($user_names) as $user_name) {
$un = trim($user_name);
// Make sure the user exists before attempting
// to add to the group
$user = get_user_by('slug', $un);
if (empty($user)) {
$error_new[] = $un;
} else {
if (!groups_join_group($group_id, $user->ID)) {
$error_new[] = $un;
} else {
$success_new[] = $un;
}
}
}
}
// Process member role changes
if (!empty($_POST['bp-groups-role']) && !empty($_POST['bp-groups-existing-role'])) {
// Before processing anything, make sure you're not
// attempting to remove the all user admins
$admin_count = 0;
foreach ((array) $_POST['bp-groups-role'] as $new_role) {
if ('admin' == $new_role) {
$admin_count++;
示例3: groups_screen_group_admin_settings
/**
* Handle the display of a group's admin/group-settings page.
*/
function groups_screen_group_admin_settings()
{
if ('group-settings' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin()) {
return false;
}
$bp = buddypress();
// If the edit form has been submitted, save the edited details.
if (isset($_POST['save'])) {
$enable_forum = isset($_POST['group-show-forum']) ? 1 : 0;
// Checked against a whitelist for security.
/** This filter is documented in bp-groups/bp-groups-admin.php */
$allowed_status = apply_filters('groups_allowed_status', array('public', 'private', 'hidden'));
$status = in_array($_POST['group-status'], (array) $allowed_status) ? $_POST['group-status'] : 'public';
// Checked against a whitelist for security.
/** This filter is documented in bp-groups/bp-groups-admin.php */
$allowed_invite_status = apply_filters('groups_allowed_invite_status', array('members', 'mods', 'admins'));
$invite_status = isset($_POST['group-invite-status']) && in_array($_POST['group-invite-status'], (array) $allowed_invite_status) ? $_POST['group-invite-status'] : 'members';
// Check the nonce.
if (!check_admin_referer('groups_edit_group_settings')) {
return false;
}
if (!groups_edit_group_settings($_POST['group-id'], $enable_forum, $status, $invite_status)) {
bp_core_add_message(__('There was an error updating group settings. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group settings were successfully updated.', 'buddypress'));
}
/**
* Fires before the redirect if a group settings has been edited and saved.
*
* @since 1.0.0
*
* @param int $id ID of the group that was edited.
*/
do_action('groups_group_settings_edited', $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/group-settings/');
}
/**
* Fires before the loading of the group admin/group-settings page template.
*
* @since 1.0.0
*
* @param int $id ID of the group that is being displayed.
*/
do_action('groups_screen_group_admin_settings', $bp->groups->current_group->id);
/**
* Filters the template to load for a group's admin/group-settings page.
*
* @since 1.0.0
*
* @param string $value Path to a group's admin/group-settings template.
*/
bp_core_load_template(apply_filters('groups_template_group_admin_settings', 'groups/single/home'));
}
示例4: groups_screen_group_admin_settings
/**
* Handle the display of a group's admin/group-settings page.
*/
function groups_screen_group_admin_settings()
{
if ('group-settings' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin()) {
return false;
}
$bp = buddypress();
// If the edit form has been submitted, save the edited details
if (isset($_POST['save'])) {
$enable_forum = isset($_POST['group-show-forum']) ? 1 : 0;
// Checked against a whitelist for security
$allowed_status = apply_filters('groups_allowed_status', array('public', 'private', 'hidden'));
$status = in_array($_POST['group-status'], (array) $allowed_status) ? $_POST['group-status'] : 'public';
// Checked against a whitelist for security
$allowed_invite_status = apply_filters('groups_allowed_invite_status', array('members', 'mods', 'admins'));
$invite_status = isset($_POST['group-invite-status']) && in_array($_POST['group-invite-status'], (array) $allowed_invite_status) ? $_POST['group-invite-status'] : 'members';
// Check the nonce
if (!check_admin_referer('groups_edit_group_settings')) {
return false;
}
if (!groups_edit_group_settings($_POST['group-id'], $enable_forum, $status, $invite_status)) {
bp_core_add_message(__('There was an error updating group settings. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group settings were successfully updated.', 'buddypress'));
}
do_action('groups_group_settings_edited', $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/group-settings/');
}
do_action('groups_screen_group_admin_settings', $bp->groups->current_group->id);
bp_core_load_template(apply_filters('groups_template_group_admin_settings', 'groups/single/home'));
}
示例5: groups_screen_group_admin_settings
function groups_screen_group_admin_settings() {
global $bp;
if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
if ( !$bp->is_item_admin )
return false;
// If the edit form has been submitted, save the edited details
if ( isset( $_POST['save'] ) ) {
$enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
$allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
$status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
/* Check the nonce first. */
if ( !check_admin_referer( 'groups_edit_group_settings' ) )
return false;
if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status ) ) {
bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
} else {
bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
}
do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/group-settings/' );
}
do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id );
bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/home' ) );
}
}
示例6: groups_screen_group_admin_settings
function groups_screen_group_admin_settings()
{
global $bp, $group_obj;
if ($bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0]) {
if (!$bp->is_item_admin) {
return false;
}
// If the edit form has been submitted, save the edited details
if (isset($_POST['save'])) {
$enable_wire = isset($_POST['group-show-wire']) ? 1 : 0;
$enable_forum = isset($_POST['group-show-forum']) ? 1 : 0;
$enable_photos = isset($_POST['group-show-photos']) ? 1 : 0;
$photos_admin_only = $_POST['group-photos-status'] != 'all' ? 1 : 0;
$status = $_POST['group-status'];
if (!groups_edit_group_settings($_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status)) {
bp_core_add_message(__('There was an error updating group settings, please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Group settings were successfully updated.', 'buddypress'));
}
do_action('groups_group_settings_edited', $group_obj->id);
bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-settings');
}
do_action('groups_screen_group_admin_settings', $group_obj->id);
bp_core_load_template(apply_filters('groups_template_group_admin_settings', 'groups/admin/group-settings'));
}
}
示例7: test_wp_idea_stream_groups_hidden_to_private
/**
* @group group_status
*/
public function test_wp_idea_stream_groups_hidden_to_private()
{
$bp = buddypress();
$group = new BP_Groups_Group($this->group_id);
$group->status = 'hidden';
$group->save();
// Set current group
$bp->groups->current_group = groups_get_group(array('group_id' => $this->group_id, 'populate_extras' => true));
$u = $this->factory->user->create();
groups_join_group($this->group_id, $u);
$idea1 = $this->factory->idea->create(array('author' => $u, 'metas' => array('group_id' => $this->group_id), 'status' => 'private'));
$idea2 = $this->factory->idea->create(array('author' => $u, 'metas' => array('group_id' => $this->group_id), 'status' => 'private'));
$updated = groups_edit_group_settings($this->group_id, false, 'private');
$ideas = wp_idea_stream_ideas_get_ideas(array('include' => array($idea1, $idea2)));
$private_ideas = wp_filter_object_list($ideas['ideas'], array('post_status' => 'private'), 'and', 'ID');
$this->assertEqualSets(array($idea1, $idea2), $private_ideas, 'Switching from hidden to private should not update the idea status');
}