Skip to:
Content
Pages
Categories
Search
Top
Bottom

non-logged in users access to private pages


  • ProfC
    Participant

    @profc

    Hi, I need an easy solution to prevent non-logged in users from accessing to private bp area and browse pages such as users page, group page etc. My web site has both public and private pages. I simply did that by hiding the above page’s link on the menu to non-logged in users, but if someone add /users on the main web address (e.g. http://www.mysite.com/users) he can read the page the same.

    Many thanks,
    Gabriele

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

  • bp-help
    Participant

    @bphelp

    @profc
    Use this plugin. Download the zip file and upload to your plugins directory. Read the readme.txt and make the adjustments in the commented code in private-community-for-bp.php before activating the plugin.
    https://github.com/bphelp/private_community_for_bp


    ProfC
    Participant

    @profc

    Thanks for your quick answer.

    I read the readme file but I did not understeand whicj commented code I have to edit.

    In my website I have 3 public page: ‘home’ , ‘radio’ , ‘contatti’, so I add these strings:

    $bphelp_my_unblocked_pages = ‘home’;
    $bphelp_my_unblocked_pages = ‘radio’;
    $bphelp_my_unblocked_pages = ‘contatti’;

    and put home in this string, since you can reach register page from home:
    $bphelp_if_I_changed_my_register_slug_it_is = ‘home’; // Replace ‘register’ if you have changed the ‘register’ slug for example to ‘sign-up’

    but those pages are still blocked.
    why?


    ProfC
    Participant

    @profc

    dear @bphelp

    I try to explain better: I need 3 pages available to all users. Those three pages are: home, radio-109, contatti (these are the short name of the pages).

    I want to stop users from accessing bp pages like members and groups pages by hot links.

    ‘registrati’ is the slug that stands for ‘register’ page on bp.

    I used private_community_for_bp-master, as you suggested me, and I edited private-community-for-bp.php in this way:

    /* Prevent logged out users from accessing bp pages */
    function bphelp_private_community(){
    global $bp_unfiltered_uri;

    $bphelp_my_unblocked_pages = ‘ ‘; // Replace ‘test’ with the name of the page you would like to make available to logged out visitors EX: ‘activity’

    $bphelp_my_unblocked_pages = ‘radio-109’; // Replace ‘test’ with the name of the page you would like to make available to logged out visitors EX: ‘activity’

    $bphelp_my_unblocked_pages = ‘contatti’; // Replace ‘test’ with the name of the page you would like to make available to logged out visitors EX: ‘activity’

    $bphelp_my_unblocked_pages = ‘registrazione’; // Replace ‘test’ with the name of the page you would like to make available to logged out visitors EX: ‘activity’

    $bphelp_if_I_changed_my_register_slug_it_is = ‘registrazione’; // Replace ‘register’ if you have changed the ‘register’ slug for example to ‘sign-up’

    if ( !is_user_logged_in() && !bp_is_register_page() && !bp_is_activation_page() && ( $bp_unfiltered_uri[0] != $bphelp_my_unblocked_pages ) )
    bp_core_redirect( get_option(‘home’) . ‘/’ . $bphelp_if_I_changed_my_register_slug_it_is );

    }
    add_action( ‘wp’, ‘bphelp_private_community’, 3 );
    /* End Prevent logged out users from accessing bp pages */

    I want that generic users can reach those pages, but at this time they are redirect to the ‘registrazione’ page. Where I wrong? What’s the name of homepage? Is it home, even if it doesn’t appear to the link?

    Thanks for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘non-logged in users access to private pages’ is closed to new replies.
Skip to toolbar