Login before viewing Users List

This topic contains 6 replies, has 3 voices, and was last updated by  antoniomartin 4 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #7917

    antoniomartin
    Free User
    Post count: 35

    Is there a way to force user login before displaying Users List like the Add Listings page?

    #7920

    Alex Rollin
    Moderator
    Post count: 27815

    There is not, but, you can set that page to draft if you aren’t using it.

    We have some new features coming up soon and we will be looking into items like that.

    If you want, you can use CSS to hide it. Can you share a link to the page?

    #7931

    antoniomartin
    Free User
    Post count: 35

    I am using the page. I just want users to login to view it. Here is the link if you would like it: https://www.staging.clinicalsupervisionsolutions.com/users/

    #7937

    Alex Rollin
    Moderator
    Post count: 27815

    Sure, try this:

    
    
    
    body.page-id-20 .sd-container {
        display: none;
    }
    
    body.page-id-20.logged-in .sd-container {
        display: initial;
    }
    

    Add that to the customizer -> Additional CSS

    #7940

    antoniomartin
    Free User
    Post count: 35

    I works but I don’t understand why. Can you give a brief explanation?

    #7943

    Patrik
    Moderator
    Post count: 1971

    Hi,

    You can try the following code by putting into functions.php file or currently active theme or via code snippets plugin:

    
    
    add_action('template_redirect', 'template_redirect_cb');
    function template_redirect_cb(){
        if(!is_user_logged_in() && is_uwp_users_page()){
            wp_redirect(site_url());
        }
    }

    Let me know if it helps or not!

    Regards,
    Patrik

    #7952

    antoniomartin
    Free User
    Post count: 35

    This is exactly what I was looking for with one exception: I changed the redirect wp_redirect(site_url()); to auth_redirect(); to direct the user to the login page.

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket