Skip to:
Content

BuddyPress.org

Changeset 13556


Ignore:
Timestamp:
08/24/2023 05:12:57 PM (19 months ago)
Author:
dcavins
Message:

Introduce bp_view_no_access_redirect_to_login_screen filter.

Use this new filter to send the user to the site login screen
when the user does not have the bp_view capability for the
current screen or situation. The default behavior is for the
user to be shown the content in the
assets/utils/restricted-access-message.php file.

See #8734.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-component.php

    r13533 r13556  
    12851285                }
    12861286            } else {
     1287
     1288                /**
     1289                 * Use this filter to send the user to the site login screen when the user does
     1290                 * not have the `bp_view` capability for the current screen or situation.
     1291                 * The default behavior is for the user to be shown the content in the
     1292                 * `assets/utils/restricted-access-message.php` file.
     1293                 *
     1294                 * Only users that are not logged in will be sent to the login screen,
     1295                 * else we can cause a redirect loop if the `bp_view` capability is not met
     1296                 * for a logged-in user.
     1297                 *
     1298                 * @since 12.0.0
     1299                 *
     1300                 * @param false Whether the user should be redirected to the site login screen.
     1301                 */
     1302                $do_redirect_to_login_screen = apply_filters( 'bp_view_no_access_redirect_to_login_screen', false );
     1303                If ( true === $do_redirect_to_login_screen && ! is_user_logged_in() ) {
     1304                    bp_core_no_access();
     1305                }
     1306
    12871307                // The current user may not access the directory page.
    12881308                $bp                    = buddypress();
Note: See TracChangeset for help on using the changeset viewer.