Skip to:
Content
Pages
Categories
Search
Top
Bottom

Make the profile not clickable for unregistered and non logged in users.


  • rafiquej
    Participant

    @rafiquej

    Hi there,

    How to make the the user profile not clickable for non logged users and logged users as well. I have the code which enables the user himself and admin to open the profile but when any other user clicks on the profile, the page redirects to the home page. What i actually want is that to disable the click function for unregistered users and registered users as well. Only admin and user can access the profile link. I don’t know if i am clear enough Lol. Here’s the code i am using.

    function private_profiles() {
    
        // Bail if not a profile page.
        if ( ! bp_is_user_profile() )
            return;
    
        // Allow admin users.
        if ( current_user_can( 'manage_options' ) )
            return;
    
        // Allow the profile owner.
        if ( bp_loggedin_user_id() == bp_displayed_user_id() )
            return;
    
        // If we get to here, redirect to homepage.
        bp_core_redirect( home_url() );
    }
    add_action( 'init', 'private_profiles' );
Viewing 1 replies (of 1 total)

  • rafiquej
    Participant

    @rafiquej

    This code redirects to the homepage.

    bp_core_redirect( home_url() );

    can we replace it with a function which disables the clickable function on the user profile?

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