Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Hiding Members Page to everybody (visitor and also members)


  • ico33
    Participant

    @ico33

    Is there a way to completely hide MEMBERS page? I mean, hiding the page from everybody: visitors but also members (user logged-in). I would like to let the page private, just the admin should view.

    Suggestion?

    Thanks a lot for your support

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

  • Brajesh Singh
    Participant

    @sbrajesh

    Please put this code in your bp-custom.php

    
    function buddydev_hide_members_directory_from_all_except_admin() {
    
    	if ( bp_is_members_directory() && ! is_super_admin() ) {
    		//should we add a message too?
    		//bp_core_add_message( 'Private page.', 'error' );
    		bp_core_redirect( site_url('/') );
    	}
    }
    add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
    

    That should do it. Hoe it helps.


    ico33
    Participant

    @ico33

    @sbrajesh

    thank you very much. I have a problem… the page bp-custom.php seems that doesn’t exist in my file manager. How is this possible?


    danbp
    Moderator

    @danbp

    It is possible because it doesn’t exist and you never noticed his mention in many topics of this forum, and perhaps never read the codex. 🙂

    Read here please:

    bp-custom.php


    ico33
    Participant

    @ico33

    @danbp thanks! I’m really new with wordpress world, and I am not a webmaster/programmer, so even if wordpress seems easy, it’s less easy for me.

    If I understood: I have to create that file, put inside the suggestion of the user “brajesh”, then save the file in the plugins’ folder. Is this enough?

    Thanks a lot


    ico33
    Participant

    @ico33

    Can you confirm?

    Thanks again


    danbp
    Moderator

    @danbp

    Yes. Anyway, best confirmation is to follow the instructions you received and to try them out !


    ico33
    Participant

    @ico33

    I mean: is it enough to create a file bp.custom.php and upload it in the right folder? or do I have in some way “say to buddypress that there is that file”? It’s enough to create it (because I don’t have that file) and upload it?


    ico33
    Participant

    @ico33

    @sbrajesh

    Hello and thanks for the support, I tried the solution suggested, but after I created and then uploaded the file bp-custom in the plugins folder I got an error in every page of the website:

    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mondolap/public_html/wp-content/plugins/bp-custom.php on line 2

    This is my file bp-custom:

    <? php
    function buddydev_hide_members_directory_from_all_except_admin() {
    
        if ( bp_is_members_directory() && ! is_super_admin() ) {
            //should we add a message too?
            //bp_core_add_message( 'Private page.', 'error' );
            bp_core_redirect( site_url('/') );
        }
    }
    add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
    ?>

    danbp
    Moderator

    @danbp

    Hi @ico33,

    bp-custom file doesn’t need a closing php tag. Remove it and see if it works.

    the first line of bp-custom contain <?php then you add your function(s)…

    <?php
    function 1
    ----
    
    function 2
    ---

    and so on. And that’s it !


    ico33
    Participant

    @ico33

    Thanks! I did it with your suggest, so the file is

    
    <? php
    function buddydev_hide_members_directory_from_all_except_admin() {
    
        if ( bp_is_members_directory() && ! is_super_admin() ) {
            //should we add a message too?
            //bp_core_add_message( 'Private page.', 'error' );
            bp_core_redirect( site_url('/') );
        }
    }
    add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );


    But every page of the website is now again a blank page with this error:

    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mondolap/public_html/wp-content/plugins/bp-custom.php on line 2


    danbp
    Moderator

    @danbp

    The function is working correctly on my install.

    Perhaps you have an issue with quotes, ie after copy/pasting the snippet from a topic where the code whas inserted without using the code button.
    Which software do you use to publish bp-custom ?

    Copy/paste following and give a try:

    function buddydev_hide_members_directory_from_all_except_admin() {
    
    if ( bp_is_members_directory() && ! is_super_admin() ) {
    //should we add a message too?
    //bp_core_add_message( 'Private page.', 'error' );
    bp_core_redirect( site_url('/') );
    }
    }
    add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );

    ico33
    Participant

    @ico33

    Nothing to do!

    Error:

    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mondolap/public_html/wp-content/plugins/bp-custom.php on line 3

    This is the bp-custom code:

    <? php

    function buddydev_hide_members_directory_from_all_except_admin() {

    if ( bp_is_members_directory() && ! is_super_admin() ) {
    //should we add a message too?
    //bp_core_add_message( ‘Private page.’, ‘error’ );
    bp_core_redirect( site_url(‘/’) );
    }
    }
    add_action( ‘bp_template_redirect’, ‘buddydev_hide_members_directory_from_all_except_admin’ );


    shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    Try changing this: <? php
    To this: <?php


    ico33
    Participant

    @ico33

    Well… i am a bit ashamed. It’s true that I’m new with wordpress and I’m not a webmaster… but damn, the problem was there @shanebp LOL

    A big THANKS to everybody here!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Resolved] Hiding Members Page to everybody (visitor and also members)’ is closed to new replies.
Skip to toolbar