Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profiles & Member List: Redirect all subscribers


  • Jens
    Participant

    @jesus-1

    I´d like to redirect users with a specific user role (subscriber). They should not be able to see
    a) single member profiles and
    b) the member list.

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)

  • shanebp
    Moderator

    @shanebp

    Determine if a user is on the Members list:
    if( bp_current_component('members') )

    Determine if a user is on a profile page:
    if ( bp_is_user() )


    Jens
    Participant

    @jesus-1

    Thanks, Shane!

    So, I would have to check, if a user is on the Members list/a profile page. Done with your code. But I would have to check, if he is a “subscriber”, too – and in this case redirect him to another url. Any hints, how to achieve that and where to place the code?


    Jens
    Participant

    @jesus-1

    Here is a solution to exclude users, that are not logged in: https://buddypress.org/support/topic/hide-profile-from-non-logged-in-users/#post-147745.

    But how to exclude/redirect users, that have the user role “subscriber”? Redirect might be working with

    <?php wp_redirect( home_url() ); exit; ?


    shanebp
    Moderator

    @shanebp

    ‘subscriber’ is a WP role.
    Google ‘wp is user subscriber’

    Current user id: bp_loggedin_user_id()


    Jens
    Participant

    @jesus-1

    Okay, seems like I really have to learn more about PHP. Via google I found https://wordpress.stackexchange.com/questions/60272/find-out-if-logged-in-user-is-not-subscriber. That gave me a rough idea, but I did not manage to change the code for a redirect.

    However, I found a workaround. I placed the following code…

    <?php if ( current_user_can('member') ) : ?>

    and

    <?php endif; ?>

    in these files:

    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/index.php (lines 27 and 144)
    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/home.php (13 and 122)

    There´s no redirection now, but the content is not visible anymore for the role “subscriber”, but visible for “member”.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar