/** * Get the max upload file size for any attachment * * @since 2.4.0 * * @param string $type A string to inform about the type of attachment * we wish to get the max upload file size for * @return int max upload file size for any attachment */ function bp_attachments_get_max_upload_file_size($type = '') { $fileupload_maxk = bp_core_get_root_option('fileupload_maxk'); if ('' === $fileupload_maxk) { $fileupload_maxk = 5120000; // 5mb; } else { $fileupload_maxk = $fileupload_maxk * 1024; } /** * Filter here to edit the max upload file size. * * @since 2.4.0 * * @param int $fileupload_maxk Max upload file size for any attachment * @param string $type The attachment type (eg: 'avatar' or 'cover_image') */ return apply_filters('bp_attachments_get_max_upload_file_size', $fileupload_maxk, $type); }
/** * Check whether the current activity about a post or a comment can be published. * * Abstracted from the deprecated `bp_blogs_record_post()`. * * @since 2.2.0 * * @param bool $return Whether the post should be published. * @param int $blog_id ID of the blog. * @param int $post_id ID of the post. * @param int $user_id ID of the post author. * @return bool True to authorize the post to be published, otherwise false. */ function bp_blogs_post_pre_publish($return = true, $blog_id = 0, $post_id = 0, $user_id = 0) { $bp = buddypress(); // If blog is not trackable, do not record the activity. if (!bp_blogs_is_blog_trackable($blog_id, $user_id)) { return false; } /* * Stop infinite loops with WordPress MU Sitewide Tags. * That plugin changed the way its settings were stored at some point. Thus the dual check. */ $sitewide_tags_blog_settings = bp_core_get_root_option('sitewide_tags_blog'); if (!empty($sitewide_tags_blog_settings)) { $st_options = maybe_unserialize($sitewide_tags_blog_settings); $tags_blog_id = isset($st_options['tags_blog_id']) ? $st_options['tags_blog_id'] : 0; } else { $tags_blog_id = bp_core_get_root_option('sitewide_tags_blog'); $tags_blog_id = intval($tags_blog_id); } /** * Filters whether or not BuddyPress should block sitewide tags activity. * * @since 2.2.0 * * @param bool $value Current status of the sitewide tags activity. */ if ((int) $blog_id == $tags_blog_id && apply_filters('bp_blogs_block_sitewide_tags_activity', true)) { return false; } /** * Filters whether or not the current blog is public. * * @since 2.2.0 * * @param int $value Value from the blog_public option for the current blog. */ $is_blog_public = apply_filters('bp_is_blog_public', (int) get_blog_option($blog_id, 'blog_public')); if (0 === $is_blog_public && is_multisite()) { return false; } return $return; }
/** * Set up bp-forums global settings. * * The BP_FORUMS_SLUG constant is deprecated, and only used here for * backwards compatibility. * * @since BuddyPress (1.5.0) * * @see BP_Component::setup_globals() for description of parameters. * * @param array $args See {@link BP_Component::setup_globals()}. */ public function setup_globals($args = array()) { $bp = buddypress(); // Define the parent forum ID if (!defined('BP_FORUMS_PARENT_FORUM_ID')) { define('BP_FORUMS_PARENT_FORUM_ID', 1); } // Define a slug, if necessary if (!defined('BP_FORUMS_SLUG')) { define('BP_FORUMS_SLUG', $this->id); } // The location of the bbPress stand-alone config file $bbconfig = bp_core_get_root_option('bb-config-location'); if ('' !== $bbconfig) { $this->bbconfig = $bbconfig; } // All globals for messaging component. // Note that global_tables is included in this array. $globals = array('slug' => BP_FORUMS_SLUG, 'root_slug' => isset($bp->pages->forums->slug) ? $bp->pages->forums->slug : BP_FORUMS_SLUG, 'has_directory' => true, 'notification_callback' => 'messages_format_notifications', 'search_string' => __('Search Forums...', 'buddypress')); parent::setup_globals($globals); }
/** * Setup globals * * The BP_XPROFILE_SLUG constant is deprecated, and only used here for * backwards compatibility. * * @since BuddyPress (1.5.0) */ public function setup_globals($args = array()) { $bp = buddypress(); // Define a slug, if necessary if (!defined('BP_XPROFILE_SLUG')) { define('BP_XPROFILE_SLUG', 'profile'); } // Assign the base group and fullname field names to constants // to use in SQL statements. // Defined conditionally to accommodate unit tests if (!defined('BP_XPROFILE_BASE_GROUP_NAME')) { define('BP_XPROFILE_BASE_GROUP_NAME', stripslashes(bp_core_get_root_option('avatar_default'))); } if (!defined('BP_XPROFILE_FULLNAME_FIELD_NAME')) { define('BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes(bp_core_get_root_option('bp-xprofile-fullname-field-name'))); } /** * Filters the supported field type IDs. * * @since BuddyPress (1.1.0) * * @param array $value Array of IDs for the supported field types. */ $this->field_types = apply_filters('xprofile_field_types', array_keys(bp_xprofile_get_field_types())); // 'option' is a special case. It is not a top-level field, so // does not have an associated BP_XProfile_Field_Type class, // but it must be whitelisted $this->field_types[] = 'option'; // Register the visibility levels. See bp_xprofile_get_visibility_levels() to filter $this->visibility_levels = array('public' => array('id' => 'public', 'label' => _x('Everyone', 'Visibility level setting', 'buddypress')), 'adminsonly' => array('id' => 'adminsonly', 'label' => _x('Only Me', 'Visibility level setting', 'buddypress')), 'loggedin' => array('id' => 'loggedin', 'label' => _x('All Members', 'Visibility level setting', 'buddypress'))); if (bp_is_active('friends')) { $this->visibility_levels['friends'] = array('id' => 'friends', 'label' => _x('My Friends', 'Visibility level setting', 'buddypress')); } // Tables $global_tables = array('table_name_data' => $bp->table_prefix . 'bp_xprofile_data', 'table_name_groups' => $bp->table_prefix . 'bp_xprofile_groups', 'table_name_fields' => $bp->table_prefix . 'bp_xprofile_fields', 'table_name_meta' => $bp->table_prefix . 'bp_xprofile_meta'); $meta_tables = array('xprofile_group' => $bp->table_prefix . 'bp_xprofile_meta', 'xprofile_field' => $bp->table_prefix . 'bp_xprofile_meta', 'xprofile_data' => $bp->table_prefix . 'bp_xprofile_meta'); $globals = array('slug' => BP_XPROFILE_SLUG, 'has_directory' => false, 'notification_callback' => 'xprofile_format_notifications', 'global_tables' => $global_tables, 'meta_tables' => $meta_tables); parent::setup_globals($globals); }
/** * Set up the Toolbar. * * @param array $wp_admin_nav Array of Admin Bar items. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user if (is_user_logged_in()) { // Setup the logged in user variables $settings_link = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug()); // Add main Settings menu $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Settings', 'buddypress'), 'href' => $settings_link); // General Account $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-general', 'title' => __('General', 'buddypress'), 'href' => $settings_link); // Notifications - only add the tab when there is something to display there. if (has_action('bp_notification_settings')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-notifications', 'title' => __('Email', 'buddypress'), 'href' => trailingslashit($settings_link . 'notifications')); } // Delete Account if (!bp_current_user_can('bp_moderate') && !bp_core_get_root_option('bp-disable-account-deletion')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-delete-account', 'title' => __('Delete Account', 'buddypress'), 'href' => trailingslashit($settings_link . 'delete-account')); } } parent::setup_admin_bar($wp_admin_nav); }
/** * Checks whether Avatar UI should be loaded. * * @since 2.3.0 * * @return bool True if Avatar UI should load, false otherwise. */ function bp_avatar_is_front_edit() { $retval = false; // No need to carry on if the current WordPress version is not supported. if (!bp_attachments_is_wp_version_supported()) { return $retval; } if (bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step()) { $retval = !bp_core_get_root_option('bp-disable-avatar-uploads'); } if (bp_is_active('groups')) { // Group creation if (bp_is_group_create() && bp_is_group_creation_step('group-avatar') && 'crop-image' !== bp_get_avatar_admin_step()) { $retval = !bp_disable_group_avatar_uploads(); // Group Manage } elseif (bp_is_group_admin_page() && bp_is_group_admin_screen('group-avatar') && 'crop-image' !== bp_get_avatar_admin_step()) { $retval = !bp_disable_group_avatar_uploads(); } } /** * Use this filter if you need to : * - Load the avatar UI for a component that is !groups or !user (return true regarding your conditions) * - Completely disable the avatar UI introduced in 2.3 (eg: __return_false()) * * @since 2.3.0 * * @param bool whether to load the Avatar UI. */ return apply_filters('bp_avatar_is_front_edit', $retval); }
/** * Constructor method. * * The arguments passed to this class constructor are of the same * format as {@link BP_Activity_Activity::get()}. * * @since 1.5.0 * * @see BP_Activity_Activity::get() for a description of the argument * structure, as well as default values. * * @param array $args { * Array of arguments. Supports all arguments from * BP_Activity_Activity::get(), as well as 'page_arg' and * 'include'. Default values for 'per_page' and 'display_comments' * differ from the originating function, and are described below. * @type string $page_arg The string used as a query parameter in * pagination links. Default: 'acpage'. * @type array|bool $include Pass an array of activity IDs to * retrieve only those items, or false to noop the 'include' * parameter. 'include' differs from 'in' in that 'in' forms * an IN clause that works in conjunction with other filters * passed to the function, while 'include' is interpreted as * an exact list of items to retrieve, which skips all other * filter-related parameters. Default: false. * @type int|bool $per_page Default: 20. * @type string|bool $display_comments Default: 'threaded'. * } */ public function __construct($args) { $bp = buddypress(); // Backward compatibility with old method of passing arguments. if (!is_array($args) || func_num_args() > 1) { _deprecated_argument(__METHOD__, '1.6', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__)); $old_args_keys = array(0 => 'page', 1 => 'per_page', 2 => 'max', 3 => 'include', 4 => 'sort', 5 => 'filter', 6 => 'search_terms', 7 => 'display_comments', 8 => 'show_hidden', 9 => 'exclude', 10 => 'in', 11 => 'spam', 12 => 'page_arg'); $func_args = func_get_args(); $args = bp_core_parse_args_array($old_args_keys, $func_args); } $defaults = array('page' => 1, 'per_page' => 20, 'page_arg' => 'acpage', 'max' => false, 'fields' => 'all', 'count_total' => false, 'sort' => false, 'include' => false, 'exclude' => false, 'in' => false, 'filter' => false, 'scope' => false, 'search_terms' => false, 'meta_query' => false, 'date_query' => false, 'filter_query' => false, 'display_comments' => 'threaded', 'show_hidden' => false, 'spam' => 'ham_only', 'update_meta_cache' => true); $r = wp_parse_args($args, $defaults); extract($r); $this->pag_arg = sanitize_key($r['page_arg']); $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']); $this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']); // Check if blog/forum replies are disabled. $this->disable_blogforum_replies = (bool) bp_core_get_root_option('bp-disable-blogforum-comments'); // Get an array of the logged in user's favorite activities. $this->my_favs = maybe_unserialize(bp_get_user_meta(bp_loggedin_user_id(), 'bp_favorite_activities', true)); // Fetch specific activity items based on ID's. if (!empty($include)) { $this->activities = bp_activity_get_specific(array('activity_ids' => explode(',', $include), 'max' => $max, 'count_total' => $count_total, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache)); // Fetch all activity items. } else { $this->activities = bp_activity_get(array('display_comments' => $display_comments, 'max' => $max, 'count_total' => $count_total, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'date_query' => $date_query, 'filter_query' => $filter_query, 'filter' => $filter, 'scope' => $scope, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache)); } // The total_activity_count property will be set only if a // 'count_total' query has taken place. if (!is_null($this->activities['total'])) { if (!$max || $max >= (int) $this->activities['total']) { $this->total_activity_count = (int) $this->activities['total']; } else { $this->total_activity_count = (int) $max; } } $this->has_more_items = $this->activities['has_more_items']; $this->activities = $this->activities['activities']; if ($max) { if ($max >= count($this->activities)) { $this->activity_count = count($this->activities); } else { $this->activity_count = (int) $max; } } else { $this->activity_count = count($this->activities); } $this->full_name = bp_get_displayed_user_fullname(); // Fetch parent content for activity comments so we do not have to query in the loop. foreach ((array) $this->activities as $activity) { if ('activity_comment' != $activity->type) { continue; } $parent_ids[] = $activity->item_id; } if (!empty($parent_ids)) { $activity_parents = bp_activity_get_specific(array('activity_ids' => $parent_ids)); } if (!empty($activity_parents['activities'])) { foreach ($activity_parents['activities'] as $parent) { $this->activity_parents[$parent->id] = $parent; } unset($activity_parents); } if ((int) $this->total_activity_count && (int) $this->pag_num) { $this->pag_links = paginate_links(array('base' => add_query_arg($this->pag_arg, '%#%'), 'format' => '', 'total' => ceil((int) $this->total_activity_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('←', 'Activity pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Activity pagination next text', 'buddypress'), 'mid_size' => 1, 'add_args' => array())); } }
/** * Handle the loading of the signup screen. */ function bp_core_screen_signup() { $bp = buddypress(); if (!bp_is_current_component('register') || bp_current_action()) { return; } // Not a directory. bp_update_is_directory(false, 'register'); // If the user is logged in, redirect away from here. if (is_user_logged_in()) { $redirect_to = bp_is_component_front_page('register') ? bp_get_members_directory_permalink() : bp_get_root_domain(); /** * Filters the URL to redirect logged in users to when visiting registration page. * * @since 1.5.1 * * @param string $redirect_to URL to redirect user to. */ bp_core_redirect(apply_filters('bp_loggedin_register_page_redirect_to', $redirect_to)); return; } $bp->signup->step = 'request-details'; if (!bp_get_signup_allowed()) { $bp->signup->step = 'registration-disabled'; // If the signup page is submitted, validate and save. } elseif (isset($_POST['signup_submit']) && bp_verify_nonce_request('bp_new_signup')) { /** * Fires before the validation of a new signup. * * @since 2.0.0 */ do_action('bp_signup_pre_validate'); // Check the base account details for problems. $account_details = bp_core_validate_user_signup($_POST['signup_username'], $_POST['signup_email']); // If there are errors with account details, set them for display. if (!empty($account_details['errors']->errors['user_name'])) { $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; } if (!empty($account_details['errors']->errors['user_email'])) { $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; } // Check that both password fields are filled in. if (empty($_POST['signup_password']) || empty($_POST['signup_password_confirm'])) { $bp->signup->errors['signup_password'] = __('Please make sure you enter your password twice', 'buddypress'); } // Check that the passwords match. if (!empty($_POST['signup_password']) && !empty($_POST['signup_password_confirm']) && $_POST['signup_password'] != $_POST['signup_password_confirm']) { $bp->signup->errors['signup_password'] = __('The passwords you entered do not match.', 'buddypress'); } $bp->signup->username = $_POST['signup_username']; $bp->signup->email = $_POST['signup_email']; // Now we've checked account details, we can check profile information. if (bp_is_active('xprofile')) { // Make sure hidden field is passed and populated. if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) { // Let's compact any profile field info into an array. $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']); // Loop through the posted fields formatting any datebox values then validate the field. foreach ((array) $profile_field_ids as $field_id) { if (!isset($_POST['field_' . $field_id])) { if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) { $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'])); } } // Create errors for required fields without values. if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id]) && !bp_current_user_can('bp_moderate')) { $bp->signup->errors['field_' . $field_id] = __('This is a required field', 'buddypress'); } } // This situation doesn't naturally occur so bounce to website root. } else { bp_core_redirect(bp_get_root_domain()); } } // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled. if (isset($_POST['signup_with_blog'])) { $active_signup = bp_core_get_root_option('registration'); if ('blog' == $active_signup || 'all' == $active_signup) { $blog_details = bp_core_validate_blog_signup($_POST['signup_blog_url'], $_POST['signup_blog_title']); // If there are errors with blog details, set them for display. if (!empty($blog_details['errors']->errors['blogname'])) { $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; } if (!empty($blog_details['errors']->errors['blog_title'])) { $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0]; } } } /** * Fires after the validation of a new signup. * * @since 1.1.0 */ do_action('bp_signup_validate'); // Add any errors to the action for the field in the template for display. if (!empty($bp->signup->errors)) { foreach ((array) $bp->signup->errors as $fieldname => $error_message) { /* * The addslashes() and stripslashes() used to avoid create_function() * syntax errors when the $error_message contains quotes. */ /** * Filters the error message in the loop. * * @since 1.5.0 * * @param string $value Error message wrapped in html. */ add_action('bp_' . $fieldname . '_errors', create_function('', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\\"error\\">" . stripslashes( \'' . addslashes($error_message) . '\' ) . "</div>" );')); } } else { $bp->signup->step = 'save-details'; // No errors! Let's register those deets. $active_signup = bp_core_get_root_option('registration'); if ('none' != $active_signup) { // Make sure the extended profiles module is enabled. if (bp_is_active('xprofile')) { // Let's compact any profile field info into usermeta. $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']); // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile(). foreach ((array) $profile_field_ids as $field_id) { if (!isset($_POST['field_' . $field_id])) { if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) { // Concatenate the values. $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; // Turn the concatenated value into a timestamp. $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value)); } } if (!empty($_POST['field_' . $field_id])) { $usermeta['field_' . $field_id] = $_POST['field_' . $field_id]; } if (!empty($_POST['field_' . $field_id . '_visibility'])) { $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility']; } } // Store the profile field ID's in usermeta. $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids']; } // Hash and store the password. $usermeta['password'] = wp_hash_password($_POST['signup_password']); // If the user decided to create a blog, save those details to usermeta. if ('blog' == $active_signup || 'all' == $active_signup) { $usermeta['public'] = isset($_POST['signup_blog_privacy']) && 'public' == $_POST['signup_blog_privacy'] ? true : false; } /** * Filters the user meta used for signup. * * @since 1.1.0 * * @param array $usermeta Array of user meta to add to signup. */ $usermeta = apply_filters('bp_signup_usermeta', $usermeta); // Finally, sign up the user and/or blog. if (isset($_POST['signup_with_blog']) && is_multisite()) { $wp_user_id = bp_core_signup_blog($blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta); } else { $wp_user_id = bp_core_signup_user($_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta); } if (is_wp_error($wp_user_id)) { $bp->signup->step = 'request-details'; bp_core_add_message($wp_user_id->get_error_message(), 'error'); } else { $bp->signup->step = 'completed-confirmation'; } } /** * Fires after the completion of a new signup. * * @since 1.1.0 */ do_action('bp_complete_signup'); } } /** * Fires right before the loading of the Member registration screen template file. * * @since 1.5.0 */ do_action('bp_core_screen_signup'); /** * Filters the template to load for the Member registration page screen. * * @since 1.5.0 * * @param string $value Path to the Member registration template to load. */ bp_core_load_template(apply_filters('bp_core_template_register', array('register', 'registration/register'))); }
/** * Render the Avatar metabox to moderate inappropriate images. * * @since 2.0.0 * * @param WP_User|null $user The WP_User object for the user being edited. */ public function user_admin_avatar_metabox($user = null) { if (empty($user->ID)) { return; } ?> <div class="avatar"> <?php echo bp_core_fetch_avatar(array('item_id' => $user->ID, 'object' => 'user', 'type' => 'full', 'title' => $user->display_name)); ?> <?php if (bp_get_user_has_avatar($user->ID)) { $query_args = array('user_id' => $user->ID, 'action' => 'delete_avatar'); if (!empty($_REQUEST['wp_http_referer'])) { $query_args['wp_http_referer'] = urlencode(wp_unslash($_REQUEST['wp_http_referer'])); } $community_url = add_query_arg($query_args, buddypress()->members->admin->edit_profile_url); $delete_link = wp_nonce_url($community_url, 'delete_avatar'); ?> <a href="<?php echo esc_url($delete_link); ?> " title="<?php esc_attr_e('Delete Profile Photo', 'buddypress'); ?> " class="bp-xprofile-avatar-user-admin"><?php esc_html_e('Delete Profile Photo', 'buddypress'); ?> </a> <?php } // Load the Avatar UI templates if user avatar uploads are enabled and current WordPress version is supported. if (!bp_core_get_root_option('bp-disable-avatar-uploads') && bp_attachments_is_wp_version_supported()) { ?> <a href="#TB_inline?width=800px&height=400px&inlineId=bp-xprofile-avatar-editor" title="<?php esc_attr_e('Edit Profile Photo', 'buddypress'); ?> " class="thickbox bp-xprofile-avatar-user-edit"><?php esc_html_e('Edit Profile Photo', 'buddypress'); ?> </a> <div id="bp-xprofile-avatar-editor" style="display:none;"> <?php bp_attachments_get_template_part('avatars/index'); ?> </div> <?php } ?> </div> <?php }
/** * Is user signup allowed? * * @return bool */ function bp_get_signup_allowed() { $bp = buddypress(); $signup_allowed = false; if (is_multisite()) { $registration = bp_core_get_root_option('registration'); if (in_array($registration, array('all', 'user'))) { $signup_allowed = true; } } else { if (bp_get_option('users_can_register')) { $signup_allowed = true; } } /** * Filters whether or not new signups are allowed. * * @since 1.5.0 * * @param bool $signup_allowed Whether or not new signups are allowed. */ return apply_filters('bp_get_signup_allowed', $signup_allowed); }
/** * Is blog signup allowed? * * Returns true if is_multisite() and blog creation is enabled at * Network Admin > Settings. * * @since 1.2.0 * * @return bool True if blog signup is allowed, otherwise false. */ function bp_get_blog_signup_allowed() { if (!is_multisite()) { return false; } $status = bp_core_get_root_option('registration'); if ('none' !== $status && 'user' !== $status) { return true; } return false; }
/** * Check blog fields validation * when using buddypress registration form on signup * * @since 1.0.2.5 * @return void */ private function _check_blog_fields() { $bp = buddypress(); $active_signup = bp_core_get_root_option('registration'); if ('blog' == $active_signup || 'all' == $active_signup) { $blog_details = bp_core_validate_blog_signup($_POST['signup_blog_url'], $_POST['signup_blog_title']); // If there are errors with blog details, set them for display. if (!empty($blog_details['errors']->errors['blogname'])) { $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; } if (!empty($blog_details['errors']->errors['blog_title'])) { $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0]; } } }
/** * @group bp_core_get_root_option */ public function test_bp_core_get_root_option_with_populated_cache() { // Back up and unset global cache. $old_options = buddypress()->site_options; buddypress()->site_options = bp_core_get_root_options(); $expected = buddypress()->site_options['avatar_default']; $this->assertSame($expected, bp_core_get_root_option('avatar_default')); }