/**
 * Handle the display of the Groups directory index.
 *
 * @since 1.0.0
 */
function groups_directory_groups_setup()
{
    if (bp_is_groups_directory()) {
        // Set group type if available.
        if (bp_is_current_action(bp_get_groups_group_type_base()) && bp_action_variable()) {
            $matched_types = bp_groups_get_group_types(array('has_directory' => true, 'directory_slug' => bp_action_variable()));
            // Redirect back to group directory if no match.
            if (empty($matched_types)) {
                bp_core_redirect(bp_get_groups_directory_permalink());
            }
            // Set our global variable.
            buddypress()->groups->current_directory_type = reset($matched_types);
        }
        bp_update_is_directory(true, 'groups');
        /**
         * Fires before the loading of the Groups directory index.
         *
         * @since 1.1.0
         */
        do_action('groups_directory_groups_setup');
        /**
         * Filters the template to load for the Groups directory index.
         *
         * @since 1.0.0
         *
         * @param string $value Path to the groups directory index template to load.
         */
        bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index'));
    }
}
 /**
  * Are we looking at something that needs group theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_group()
 {
     // Bail if not looking at a group.
     if (!bp_is_groups_component()) {
         return;
     }
     // Group Directory.
     if (!bp_current_action() && !bp_current_item()) {
         bp_update_is_directory(true, 'groups');
         /**
          * Fires at the start of the group theme compatibility setup.
          *
          * @since 1.1.0
          */
         do_action('groups_directory_groups_setup');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Creating a group.
     } elseif (bp_is_groups_component() && bp_is_current_action('create')) {
         add_filter('bp_get_buddypress_template', array($this, 'create_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'create_content'));
         // Group page.
     } elseif (bp_is_single_item()) {
         add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'single_content'));
     }
 }
/**
 * draft_article_screen()
 *
 * Sets up and displays the screen output for the sub nav item "social-articles/screen-two"
 */
function pending_articles_screen()
{
    global $bp;
    bp_update_is_directory(true, 'pending_articles');
    do_action('pending_articles_screen');
    bp_core_load_template(apply_filters('pending_articles_screen', 'members/single/articles'));
}
 /**
  * Are we looking at something that needs Blogs theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_blogs()
 {
     // Bail if not looking at a group.
     if (!bp_is_blogs_component()) {
         return;
     }
     // Bail if looking at a users sites.
     if (bp_is_user()) {
         return;
     }
     // Blog Directory.
     if (is_multisite() && !bp_current_action()) {
         bp_update_is_directory(true, 'blogs');
         /**
          * Fires if in the blog directory and BuddyPress needs Blog theme compatibility,
          * before the actions and filters are added.
          *
          * @since 1.5.0
          */
         do_action('bp_blogs_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Create blog.
     } elseif (is_user_logged_in() && bp_blog_signup_enabled()) {
         add_filter('bp_get_buddypress_template', array($this, 'create_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'create_content'));
     }
 }
/**
 * Activity screen index
 *
 * @since 1.5.0
 *
 * @uses bp_displayed_user_id()
 * @uses bp_is_activity_component()
 * @uses bp_current_action()
 * @uses bp_update_is_directory()
 * @uses do_action() To call the 'bp_activity_screen_index' hook
 * @uses bp_core_load_template()
 * @uses apply_filters() To call the 'bp_activity_screen_index' hook
 */
function bp_activity_screen_index()
{
    if (!bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action()) {
        bp_update_is_directory(true, 'activity');
        do_action('bp_activity_screen_index');
        bp_core_load_template(apply_filters('bp_activity_screen_index', 'activity/index'));
    }
}
Example #6
0
function bp_blogs_screen_index()
{
    if (is_multisite() && bp_is_blogs_component() && !bp_current_action()) {
        bp_update_is_directory(true, 'blogs');
        do_action('bp_blogs_screen_index');
        bp_core_load_template(apply_filters('bp_blogs_screen_index', 'blogs/index'));
    }
}
/**
 * Handles the display of the members directory index
 *
 * @global object $bp
 *
 * @uses bp_is_user()
 * @uses bp_is_current_component()
 * @uses do_action()
 * @uses bp_core_load_template()
 * @uses apply_filters()
 */
function bp_members_screen_index()
{
    if (!bp_is_user() && bp_is_members_component()) {
        bp_update_is_directory(true, 'members');
        do_action('bp_members_screen_index');
        bp_core_load_template(apply_filters('bp_members_screen_index', 'members/index'));
    }
}
/**
 * Load the index page 
 */
function bp_portfolio_directory_setup()
{
    if (bp_is_portfolio_component() && !bp_current_action() && !bp_current_item()) {
        bp_update_is_directory(true, 'portfolio');
        do_action('bp_portfolio_directory_setup');
        bp_core_load_template(apply_filters('portfolio_directory_template', BP_PORTFOLIO_TEMPLATE . '/index'));
    }
}
function groups_directory_groups_setup()
{
    if (bp_is_groups_component() && !bp_current_action() && !bp_current_item()) {
        bp_update_is_directory(true, 'groups');
        do_action('groups_directory_groups_setup');
        bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index'));
    }
}
function bp_forums_directory_forums_setup()
{
    global $bp;
    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 (!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);
                }
                $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'));
    }
}
/**
 * [task_breaker_bp_projects_screen_index description]
 * @return void
 */
function task_breaker_bp_projects_screen_index()
{
    // Check if on current project directory page.
    if (!bp_displayed_user_id() && bp_is_current_component('projects') && !bp_current_action()) {
        bp_update_is_directory(true, 'projects');
        // ... before using bp_core_load_template to ask BuddyPress
        // to load the template bp-plugin (which is located in
        // BP_PLUGIN_DIR . '/templates/bp-plugin.php)
        bp_core_load_template(apply_filters('task_breaker_bp_projects_screen_index', 'project-loop'));
    }
}
Example #12
0
/**
 * If your component uses a top-level directory, this function will catch the requests and load
 * the index page.
 *
 * @package BuddyPress_Template_Pack
 * @since 1.6
 */
function bp_course_directory_setup()
{
    if (bp_is_course_component() && !bp_current_action() && !bp_current_item()) {
        // This wrapper function sets the $bp->is_directory flag to true, which help other
        // content to display content properly on your directory.
        bp_update_is_directory(true, BP_COURSE_SLUG);
        // Add an action so that plugins can add content or modify behavior
        do_action('bp_course_directory_setup');
        bp_core_load_template(apply_filters('course_directory_template', 'course/index'));
    }
}
/**
 * Load the top-level Blogs directory.
 */
function bp_blogs_screen_index()
{
    if (bp_is_blogs_directory()) {
        bp_update_is_directory(true, 'blogs');
        /**
         * Fires right before the loading of the top-level Blogs screen template file.
         *
         * @since 1.0.0
         */
        do_action('bp_blogs_screen_index');
        bp_core_load_template(apply_filters('bp_blogs_screen_index', 'blogs/index'));
    }
}
 /**
  * Are we looking at either the registration or activation pages?
  *
  * @since 1.7.0
  */
 public function is_registration()
 {
     // Bail if not looking at the registration or activation page.
     if (!bp_is_register_page() && !bp_is_activation_page()) {
         return;
     }
     // Not a directory.
     bp_update_is_directory(false, 'register');
     // Setup actions.
     add_filter('bp_get_buddypress_template', array($this, 'template_hierarchy'));
     add_action('bp_template_include_reset_dummy_post_data', array($this, 'dummy_post'));
     add_filter('bp_replace_the_content', array($this, 'dummy_content'));
 }
Example #15
0
 /**
  * Are we looking at Gallery or Media Directories?
  *
  */
 public function is_directory()
 {
     // Bail if not looking at the registration or activation page
     if (!mpp_is_gallery_directory()) {
         return;
     }
     bp_set_theme_compat_active(true);
     buddypress()->theme_compat->use_with_current_theme = true;
     // Not a directory
     bp_update_is_directory(true, 'mediapress');
     // Setup actions
     add_filter('bp_get_buddypress_template', array($this, 'template_hierarchy'));
     add_action('bp_template_include_reset_dummy_post_data', array($this, 'dummy_post'));
     add_filter('bp_replace_the_content', array($this, 'directory_content'));
 }
/**
 * Load the Activity directory.
 *
 * @since 1.5.0
 *
 * @uses bp_displayed_user_id()
 * @uses bp_is_activity_component()
 * @uses bp_current_action()
 * @uses bp_update_is_directory()
 * @uses do_action() To call the 'bp_activity_screen_index' hook.
 * @uses bp_core_load_template()
 * @uses apply_filters() To call the 'bp_activity_screen_index' hook.
 */
function bp_activity_screen_index()
{
    if (bp_is_activity_directory()) {
        bp_update_is_directory(true, 'activity');
        /**
         * Fires right before the loading of the Activity directory screen template file.
         *
         * @since 1.5.0
         */
        do_action('bp_activity_screen_index');
        /**
         * Filters the template to load for the Activity directory screen.
         *
         * @since 1.5.0
         *
         * @param string $template Path to the activity template to load.
         */
        bp_core_load_template(apply_filters('bp_activity_screen_index', 'activity/index'));
    }
}
/**
 * Handle the display of the Groups directory index.
 *
 * @since 1.0.0
 */
function groups_directory_groups_setup()
{
    if (bp_is_groups_directory()) {
        bp_update_is_directory(true, 'groups');
        /**
         * Fires before the loading of the Groups directory index.
         *
         * @since 1.1.0
         */
        do_action('groups_directory_groups_setup');
        /**
         * Filters the template to load for the Groups directory index.
         *
         * @since 1.0.0
         *
         * @param string $value Path to the groups directory index template to load.
         */
        bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index'));
    }
}
 /**
  * Set up the theme compatibility hooks, if we're looking at an activity page.
  *
  * @since 1.7.0
  */
 public function is_activity()
 {
     // Bail if not looking at a group.
     if (!bp_is_activity_component()) {
         return;
     }
     // Activity Directory.
     if (!bp_displayed_user_id() && !bp_current_action()) {
         bp_update_is_directory(true, 'activity');
         /** This action is documented in bp-activity/bp-activity-screens.php */
         do_action('bp_activity_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Single activity.
     } elseif (bp_is_single_activity()) {
         add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'single_dummy_content'));
     }
 }
 /**
  * Are we looking at something that needs group theme compatability?
  *
  * @since BuddyPress (1.7)
  */
 public function is_blogs()
 {
     // Bail if not looking at a group
     if (!bp_is_blogs_component()) {
         return;
     }
     // Bail if looking at a users sites
     if (bp_is_user()) {
         return;
     }
     // Blog Directory
     if (is_multisite() && !bp_current_action()) {
         bp_update_is_directory(true, 'blogs');
         do_action('bp_blogs_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Create blog
     } elseif (is_user_logged_in() && bp_blog_signup_enabled()) {
         add_filter('bp_get_buddypress_template', array($this, 'create_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'create_content'));
     }
 }
 /**
  * Are we looking at something that needs members theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_members()
 {
     // Bail if not looking at the members component or a user's page.
     if (!bp_is_members_component() && !bp_is_user()) {
         return;
     }
     // Members Directory.
     if (!bp_current_action() && !bp_current_item()) {
         bp_update_is_directory(true, 'members');
         /**
          * Fires if looking at Members directory when needing theme compat.
          *
          * @since 1.5.0
          */
         do_action('bp_members_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // User page.
     } elseif (bp_is_user()) {
         // If we're on a single activity permalink page, we shouldn't use the members
         // template, so stop here!
         if (bp_is_active('activity') && bp_is_single_activity()) {
             return;
         }
         /**
          * Fires if looking at Members user page when needing theme compat.
          *
          * @since 1.5.0
          */
         do_action('bp_members_screen_display_profile');
         add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'single_dummy_content'));
     }
 }
 /**
  * Are we looking at something that needs group theme compatability?
  *
  * @since BuddyPress (1.7)
  */
 public function is_checkin()
 {
     if (!bp_current_action() && !bp_displayed_user_id() && bp_is_current_component('checkins')) {
         bp_update_is_directory(true, 'checkins');
         do_action('checkins_directory_checkins_setup');
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     }
     if (bp_checkins_is_place_home()) {
         if (bp_checkins_is_single_place()) {
             do_action('bp_checkins_screen_is_single_place');
             add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_place_dummy_post'));
             add_filter('bp_replace_the_content', array($this, 'single_place_content'));
         } else {
             if (bp_checkins_is_category_place()) {
                 add_action('bp_template_include_reset_dummy_post_data', array($this, 'place_category_dummy_post'));
                 add_filter('bp_replace_the_content', array($this, 'place_category_content'));
             } else {
                 add_action('bp_template_include_reset_dummy_post_data', array($this, 'place_home_dummy_post'));
                 add_filter('bp_replace_the_content', array($this, 'place_home_content'));
             }
         }
     }
 }
Example #22
0
function bp_dtheme_object_template_loader()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    /**
     * AJAX requests happen too early to be seen by bp_update_is_directory()
     * so we do it manually here to ensure templates load with the correct
     * context. Without this check, templates will load the 'single' version
     * of themselves rather than the directory version.
     */
    if (!bp_current_action()) {
        bp_update_is_directory(true, bp_current_component());
    }
    // Sanitize the post object
    $object = esc_attr($_POST['object']);
    // Locate the object template
    locate_template(array("{$object}/{$object}-loop.php"), true);
}
/**
 * Load the template loop for the current object.
 *
 * @return string Prints template loop for the specified object
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_object_template_loader()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if no object passed
    if (empty($_POST['object'])) {
        return;
    }
    // Sanitize the object
    $object = sanitize_title($_POST['object']);
    // Bail if object is not an active component to prevent arbitrary file inclusion
    if (!bp_is_active($object)) {
        return;
    }
    /**
     * AJAX requests happen too early to be seen by bp_update_is_directory()
     * so we do it manually here to ensure templates load with the correct
     * context. Without this check, templates will load the 'single' version
     * of themselves rather than the directory version.
     */
    if (!bp_current_action()) {
        bp_update_is_directory(true, bp_current_component());
    }
    $template_part = $object . '/' . $object . '-loop';
    // The template part can be overridden by the calling JS function
    if (!empty($_POST['template'])) {
        $template_part = sanitize_option('upload_path', $_POST['template']);
    }
    // Locate the object template
    bp_get_template_part($template_part);
    exit;
}
/**
 * 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')));
}
function bp_core_screen_signup()
{
    global $bp, $wpdb;
    if (!bp_is_current_component('register')) {
        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()) {
        if (bp_is_component_front_page('register')) {
            $redirect_to = bp_get_root_domain() . '/' . bp_get_members_root_slug();
        } else {
            $redirect_to = bp_get_root_domain();
        }
        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';
    } elseif (isset($_POST['signup_submit'])) {
        // Check the nonce
        check_admin_referer('bp_new_signup');
        // 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->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->site_options['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];
                }
            }
        }
        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) {
                add_action('bp_' . $fieldname . '_errors', create_function('', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\\"error\\">' . $error_message . '</div>" );'));
            }
        } else {
            $bp->signup->step = 'save-details';
            // No errors! Let's register those deets.
            $active_signup = !empty($bp->site_options['registration']) ? $bp->site_options['registration'] : '';
            if ('none' != $active_signup) {
                // 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
                foreach ((array) $profile_field_ids as $field_id) {
                    if (!isset($_POST['field_' . $field_id])) {
                        if (isset($_POST['field_' . $field_id . '_day'])) {
                            $_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']));
                        }
                    }
                    if (!empty($_POST['field_' . $field_id])) {
                        $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
                    }
                }
                // 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;
                }
                $usermeta = apply_filters('bp_signup_usermeta', $usermeta);
                // Finally, sign up the user and/or blog
                if (isset($_POST['signup_with_blog']) && is_multisite()) {
                    bp_core_signup_blog($blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta);
                } else {
                    bp_core_signup_user($_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta);
                }
                $bp->signup->step = 'completed-confirmation';
            }
            do_action('bp_complete_signup');
        }
    }
    do_action('bp_core_screen_signup');
    bp_core_load_template(apply_filters('bp_core_template_register', 'registration/register'));
}
 /**
  * Are we looking at something that needs docs theme compatability?
  *
  * @since 1.3
  */
 public function is_docs()
 {
     $is_docs = bp_docs_is_docs_component();
     if (bp_is_active('groups') && bp_is_group() && bp_is_current_action(buddypress()->bp_docs->slug)) {
         $is_docs = true;
     }
     // Bail if not looking at the docs component
     if (!$is_docs) {
         return;
     }
     add_filter('bp_get_template_stack', array($this, 'add_plugin_templates_to_stack'));
     add_filter('bp_get_buddypress_template', array($this, 'query_templates'));
     add_filter('bp_use_theme_compat_with_current_theme', 'bp_docs_do_theme_compat');
     if (bp_docs_is_global_directory() || bp_docs_is_mygroups_directory()) {
         bp_update_is_directory(true, 'docs');
         do_action('bp_docs_screen_index');
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     } else {
         if (bp_docs_is_existing_doc()) {
             if (bp_docs_is_doc_history()) {
                 $this->single_content_template = 'docs/single/history';
                 add_filter('bp_force_comment_status', '__return_false');
             } else {
                 if (bp_docs_is_doc_edit()) {
                     $this->single_content_template = 'docs/single/edit';
                     add_filter('bp_force_comment_status', '__return_false');
                 } else {
                     $this->single_content_template = 'docs/single/index';
                     add_filter('bp_docs_allow_comment_section', '__return_false');
                     // Necessary as of BP 1.9.2
                     remove_action('bp_replace_the_content', 'bp_theme_compat_toggle_is_page', 9999);
                 }
             }
             add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
             add_filter('bp_replace_the_content', array($this, 'single_content'));
         } else {
             if (bp_docs_is_doc_create()) {
                 add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
                 add_filter('bp_replace_the_content', array($this, 'create_content'));
             }
         }
     }
 }
 /**
  * Set up BuddyDrive directory page
  *
  * @package BuddyDrive Component
  * @subpackage Screens
  * @since 1.2.0
  */
 public function directory_setup()
 {
     if (bp_is_current_component('buddydrive') && !bp_displayed_user_id()) {
         // This wrapper function sets the $bp->is_directory flag to true, which help other
         // content to display content properly on your directory.
         bp_update_is_directory(true, 'buddydrive');
         // Add an action so that plugins can add content or modify behavior
         do_action('buddydrive_screen_index');
         self::load_template('buddydrive', 'directory');
     }
 }
Example #28
0
 /**
  * Are we looking at something that needs docs theme compatability?
  *
  * @since 1.3
  */
 public function is_docs()
 {
     // Bail if not looking at the docs component
     if (!bp_docs_is_docs_component()) {
         return;
     }
     add_filter('bp_get_template_stack', array($this, 'add_plugin_templates_to_stack'));
     add_filter('bp_get_buddypress_template', array($this, 'query_templates'));
     if (bp_docs_is_global_directory()) {
         bp_update_is_directory(true, 'docs');
         do_action('bp_docs_screen_index');
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     } else {
         if (bp_docs_is_existing_doc()) {
             if (bp_docs_is_doc_history()) {
                 $this->single_content_template = 'docs/single/history';
                 add_filter('bp_force_comment_status', '__return_false');
             } else {
                 if (bp_docs_is_doc_edit()) {
                     $this->single_content_template = 'docs/single/edit';
                     add_filter('bp_force_comment_status', '__return_false');
                 } else {
                     $this->single_content_template = 'docs/single/index';
                     add_filter('bp_docs_allow_comment_section', '__return_false');
                 }
             }
             add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
             add_filter('bp_replace_the_content', array($this, 'single_content'));
         } else {
             if (bp_docs_is_doc_create()) {
                 add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
                 add_filter('bp_replace_the_content', array($this, 'create_content'));
             }
         }
     }
 }
 /**
  * Are we looking at something that needs old forum theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_legacy_forum()
 {
     // Bail if not looking at a group.
     if (!bp_is_forums_component()) {
         return;
     }
     // Forum Directory.
     if ((!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('bp_forums_directory_forums_setup');
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     }
 }
Example #30
0
/**
 * Redirect the view request.
 */
function humcore_deposits_view()
{
    global $wp;
    if (humcore_is_deposit_view()) {
        bp_update_is_directory(false, 'humcore_deposits');
        do_action('humcore_deposits_view');
        $deposit_id = $wp->query_vars['deposits_item'];
        $deposit_datastream = $wp->query_vars['deposits_datastream'];
        if (empty($deposit_id) || empty($deposit_datastream)) {
            bp_do_404();
            return;
        }
        $deposit_filename = $wp->query_vars['deposits_filename'];
        $views_meta_key = sprintf('_total_views_%s_%s', $deposit_datastream, $deposit_id);
        $deposit_post_id = humcore_get_deposit_post_id($deposit_id);
        $post_data = get_post($deposit_post_id);
        $total_views = get_post_meta($deposit_post_id, $views_meta_key, true) + 1;
        // views counted at file level
        if ($post_data->post_author != bp_loggedin_user_id()) {
            $post_meta_ID = update_post_meta($deposit_post_id, $views_meta_key, $total_views);
        }
        $view_url = sprintf('/deposits/objects/%1$s/datastreams/%2$s/content', $deposit_id, $deposit_datastream);
        wp_redirect($view_url);
        exit;
    }
}