Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 6 replies - 26 through 31 (of 31 total)
  • @mossyoak

    Participant

    I just read the new Codex on child themes- so it should work with any theme- (answered my own question)

    Thank you for putting up with another newbie guys 🙂

    Best

    @mossyoak

    Participant

    Thanks for the feedback

    I think I understand now- the profile page has activity on it so it’s not possible to do what that way, and it’s linked to the member page because that is showing profiles.

    I could hide things from members with template overrides as you suggest- but I’m not sure if it will work with my theme being a child theme of Twenty Thirteen. If I put the BuddyPress override template files in my child theme will it work?

    Thanks

    @mossyoak

    Participant

    Hi @shanebp and @henrywright-1

    Thanks for your help- I agree with Shanebp that his function does the same thing and is simpler, however I still have the same problem in that it stops access to the members PROFILE page.

    I think this must be a problem with BuddyPress though- maybe it’s a bug?

    Anyway thank you both for helping with the functions I think it will be handy for other things until I sort that problem out.

    @mossyoak

    Participant

    Hi
    Thanks for your help again
    I tried your function

    function bp_my_restrict() {
       global $bp;
       $user_id = bp_loggedin_user_id(); 
       $user = new WP_User( $user_id );
    	
          if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
    
             if ( ( $user->roles[0] != 'administrator' ) ) {
                wp_redirect( $bp->loggedin_user->domain );
    	    exit();
    	 }
          }
    }
    add_action('wp','bp_my_restrict');

    But it gave a redirect loop error- I think it is because these conditionals are stopping the profile page being accessed for users lower than admin so trying to redirect to it is just looping.

    I changed the redirect to the home page which stopped the constant loop- but users who are not admin can still not access the profile page- these conditionals are stopping that which is a bit odd.

    // BuddyPress restrict activity and members page
    function bp_my_restrict() {
    global $bp;
    $user_id = bp_loggedin_user_id();
    $user = new WP_User( $user_id );
    
    if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
    if ( ( $user->roles[0] != 'administrator' ) ) {
    wp_redirect( home_url() ); exit;
    }
    }
    }
    add_action('wp','bp_my_restrict');

    Thank you for your help.

    @mossyoak

    Participant

    There is still a problem though in that if I do this it stops any member who is not an admin level user accessing their profile page. Not sure why it should affect that- tried with just the activity conditional and it stops profile page access as well.

    elseif (bp_is_current_component( 'members' ) || bp_is_current_component( 'activity' )) :
    get_header('restrict');

    I’m using a header-restrict.php which redirects them with this redirect at the very top of it:

    <?php if(!current_user_can('delete_others_pages')) { wp_redirect( home_url() ); exit; } ?>

    Any ideas?

    @mossyoak

    Participant

    Thanks for your help Henry- I tried the is_page conditional but it does not work with the BuddyPress Pages.

    So I tried bp_is_Page which worked, but was depecated.
    Then I tried
    bp_is_current_component( 'activity' ) || bp_is_current_component( 'members' )
    and they work for what I want.

    Thanks for your feedback it helped a lot 🙂

    Chris

Viewing 6 replies - 26 through 31 (of 31 total)
Skip to toolbar