Skip to:
Content

BuddyPress.org

Ticket #6123: 6123.patch

File 6123.patch, 4.4 KB (added by imath, 10 years ago)
  • src/bp-core/bp-core-catchuri.php

    diff --git src/bp-core/bp-core-catchuri.php src/bp-core/bp-core-catchuri.php
    index a0dcb8a..c433b8a 100644
    function bp_core_set_uri_globals() { 
    269269                                        return;
    270270                                }
    271271
    272                                 // If the displayed user is marked as a spammer, 404 (unless logged-
     272                                // If the displayed user is marked as a spammer or the account is not active, 404 (unless logged-
    273273                                // in user is a super admin)
    274                                 if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
    275                                         if ( bp_current_user_can( 'bp_moderate' ) ) {
    276                                                 bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' );
    277                                         } else {
     274                                if ( bp_displayed_user_id() ) {
     275
     276                                        // Do not display a "not activated" signup as a member
     277                                        if ( ! bp_is_signup_activated( bp_displayed_user_id() ) ) {
    278278                                                bp_do_404();
    279279                                                return;
    280280                                        }
     281
     282                                        // Only display spammer if the user is a super admin
     283                                        if ( bp_is_user_spammer( bp_displayed_user_id() ) ) {
     284                                                if ( bp_current_user_can( 'bp_moderate' ) ) {
     285                                                        bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' );
     286                                                } else {
     287                                                        bp_do_404();
     288                                                        return;
     289                                                }
     290                                        }
    281291                                }
    282292
    283293                                // Bump the offset
  • src/bp-members/bp-members-functions.php

    diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php
    index 72a035d..e8b2e4f 100644
    function bp_is_user_spammer( $user_id = 0 ) { 
    977977}
    978978
    979979/**
     980 * Check whether a signup has been activated.
     981 *
     982 * On non multisite config, a not activated signup account can be displayed as a member.
     983 * In case BP_SIGNUPS_SKIP_USER_CREATION is not set to true, we keep on creating the user,
     984 * so we need to check if the user status is set to 2.
     985 *
     986 * @since BuddyPress (2.2.0)
     987 *
     988 * @param int $user_id The ID for the user.
     989 * @return bool True if signup has been activated, otherwise false.
     990 */
     991function bp_is_signup_activated( $user_id = 0 ) {
     992
     993        // No user to check
     994        if ( empty( $user_id ) ) {
     995                return false;
     996        }
     997
     998        $bp = buddypress();
     999
     1000        // Assume signup is not activated
     1001        $is_activated = false;
     1002
     1003        // Setup our user
     1004        $user = false;
     1005
     1006        // Get locally-cached data if available
     1007        switch ( $user_id ) {
     1008                case bp_loggedin_user_id() :
     1009                        $user = ! empty( $bp->loggedin_user->userdata ) ? $bp->loggedin_user->userdata : false;
     1010                        break;
     1011
     1012                case bp_displayed_user_id() :
     1013                        $user = ! empty( $bp->displayed_user->userdata ) ? $bp->displayed_user->userdata : false;
     1014                        break;
     1015        }
     1016
     1017        // Manually get userdata if still empty
     1018        if ( empty( $user ) ) {
     1019                $user = get_userdata( $user_id );
     1020        }
     1021
     1022        /**
     1023         * User found
     1024         * Check the network config to eventually get the user status
     1025         */
     1026        if ( ! empty( $user ) ) {
     1027                if ( ! bp_is_network_activated() ) {
     1028                        $is_activated = 2 != $user->user_status;
     1029
     1030                // When BuddyPress is network activated, as it's a multisite config
     1031                // users are not created till the signup hasn't been activated.
     1032                // having a user set, means the signup has been activated.
     1033                } else {
     1034                        $is_activated = true;
     1035                }
     1036        }
     1037
     1038        /**
     1039         * Filters whether a signup has been activated.
     1040         *
     1041         * @since BuddyPress (2.2.0)
     1042         *
     1043         * @param bool $is_activated Whether or not signup has been activated.
     1044         * @param WP_User the user object
     1045         */
     1046        return apply_filters( 'bp_is_signup_activated', (bool) $is_activated, $user );
     1047}
     1048
     1049/**
    9801050 * Check whether a user has been marked as deleted.
    9811051 *
    9821052 * @param int $user_id The ID for the user.
  • src/bp-members/bp-members-loader.php

    diff --git src/bp-members/bp-members-loader.php src/bp-members/bp-members-loader.php
    index ecdf91e..8427cca 100644
    class BP_Members_Component extends BP_Component { 
    199199                        // users without the cap trying to access a spammer's subnav page will get
    200200                        // redirected to the root of the spammer's profile page.  this occurs by
    201201                        // by removing the component in the canonical stack.
    202                         if ( bp_is_user_spammer( bp_displayed_user_id() ) && ! bp_current_user_can( 'bp_moderate' ) ) {
     202                        if ( ( bp_is_user_spammer( bp_displayed_user_id() ) && ! bp_current_user_can( 'bp_moderate' ) ) || ! bp_is_signup_activated( bp_displayed_user_id() ) ) {
    203203                                unset( $bp->canonical_stack['component'] );
    204204                        }
    205205                }