Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Copa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Como restringir o acesso ao site WordPress por IP ou usuários conectados

Você está prestes a lançar um novo produto e desenvolveu um ótimo site para ele usando a plataforma de publicação na Web favorita do mundo, o WordPress. Você quer testá-lo ao vivo em seu próprio domínio e hospedagem, mas ainda não está pronto para torná-lo público. Anteriormente, em outro artigo, falamos sobre como proteger o WordPress com senha sem registro de usuário. Que tal limitar o acesso a um site para visitantes que estejam conectados ou que tenham permissão de acesso por endereços IP? Neste artigo, mostraremos como restringir o acesso ao site do WordPress por IP ou por usuários conectados.

Tutorial em vídeo

Subscribe to WPBeginner

Se você não gostar do vídeo ou precisar de mais instruções, continue lendo.

A primeira coisa que você precisa fazer é instalar e ativar o plugin Restricted Site Access. Depois de ativar o plug-in, vá para Settings ” Reading (Configurações ” Leitura). Role para baixo até a parte inferior e você verá opções para configurar o acesso restrito.

Restricting access to a site for logged in users or specific IP address

Usando o plug-in Restricted Site Access, você pode restringir o acesso a um site WordPress somente para usuários conectados ou para pessoas com endereços IP específicos. Você também pode optar por redirecionar os usuários sem acesso ao site, enviando-os para a página de login, redirecionando-os para outro endereço da Web, exibindo uma mensagem personalizada ou até mesmo redirecionando-os para uma página específica (página em breve) que você criou no mesmo site. O recurso Restringir por IP é muito útil se você quiser que vários funcionários do escritório tenham acesso ao projeto de desenvolvimento sem exigir que eles se registrem como usuários.

Esse plug-in pode ser extremamente útil para testes beta do seu site antes do lançamento de um produto. Também é bom para criar blogs privados apenas para amigos e familiares. Esperamos que este artigo o ajude a executar seus projetos de forma discreta. Você tem outras maneiras que usou para restringir o acesso ao site do WordPress? Compartilhe conosco nos comentários abaixo.

Divulgação: Nosso conteúdo é apoiado pelo leitor. Isso significa que, se você clicar em alguns de nossos links, poderemos receber uma comissão. Veja como o WPBeginner é financiado, por que isso é importante e como você pode nos apoiar. Aqui está nosso processo editorial.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

O kit de ferramentas definitivo WordPress

Obtenha acesso GRATUITO ao nosso kit de ferramentas - uma coleção de produtos e recursos relacionados ao WordPress que todo profissional deve ter!

Reader Interactions

25 ComentáriosDeixe uma resposta

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Jeff

    Can you restrict by IP by role? We want to limit by IP user logins that have full admin rights. Subscribers, Authors, and Editors will not be limited by IP address.

    • WPBeginner Support

      We do not have a specific recommendation for role-specific limitations at the moment but we will be sure to share if we find a method we would recommend.

      Administrador

  3. Prince Lee

    I was wondering if there was a way to restrict my signup page to only visitors from a given location

    • WPBeginner Support

      You would normally need a security plugin to achieve something like that.

      Administrador

  4. Terry

    I think this plugin is great for my wholesale accounts. but the end user (retail) for me is a customer that has to approve designs. I do not understand how to make the private page with password open for them while keeping the wholesale side ip protected. Is there a plugin that allows access by page while restricting by ip address. The password feature for the wholesale side is too vulnerable to being shared.

  5. chris

    According to the FAQ’s here is a way to make exceptions for specific pages:

    add_filter(‘restricted_site_access_is_restricted’,’impressum_override’,10,2);

    function impressum_override( $is_restricted, $wp ) {
    // check query variables to see if this is the feed
    if ( ! empty( $wp->query_vars[‘pagename’] != ‘name-of-page’ ) ) {
    $is_restricted = false;
    }
    return $is_restricted;
    }

  6. Eran

    The only problem is that this plugin restricts the access to lost password page as well.. this is a problem..

    • Jim Gore

      I also liked this simple and effective plugin, until I discovered that the lost password page couldn’t be reached. I also tried another nice plugin (restrict site access), also simple to set up & effective, but it suffered the same problem. The author of that plugin suggested that the problem could be resolved by hooking code in to handle that page.

  7. JR

    Thanks a lot !!! This plugin rocks…I was exactly looking for this ..God Bless You

  8. Shoeb

    Hi,
    How to handle the scenario with the Dynamic IP addresses. If we unrestrict certain IP addresses then every time the IP address will get change. Then what to do in this situation ?

  9. Mariska Van de Langenberg

    If you would have a subscription sign up for a product as well as a registration as affiliate on your site….would there be an option to avoid people to sign up as affiliate first and then subscribe to the product in order to get commissioned on them? Like a check on IP amongst the affiliate IP’s?

  10. kate

    I have a problem when my members sign up they are taken to payment page but if they click off this page they can log in without paying. How do i restrict their access until they have paid the fee

    in a nutshell How can i restrict access to my members until they pay

  11. Mona

    Can you please clarify the following:

    By restricting site access to those who are “logged in” – does that mean users have to set up a Wordpress account? I’m trying to make it as easy as possible for the non-savvy computer user for accessing a family website.

    Also, do restricted access plugins only work on self hosted sites? What about free sites like Wordpress.com?

    Thanks!

    • Editorial Staff

      Most techniques mentioned on this site including this one are for self-hosted WordPress and will not work on free WordPress.com

      Administrador

  12. Ruchi

    Is there a way to restrict users to only a certain section on the site, where they can access product data etc. based on an email login? I’m an amateur webmaster and have been struggling with this.

    • Editorial Staff

      Yes. You would have to use one of the many membership plugins such as S2 members or Easy Digital Downloads etc.

      Administrador

      • Ruchi

        Thanks. I ended up using word press access control since it allowed more customization, been workin like a charm..
        Used a lot of tips from your website though. You guys are doing a great job! Thanks much!

  13. Simon

    So basically install a plugin… what a very informative article.

    If anyone else is interested you can add code in your functions file to prevent anyone who is not logged in from viewing your site:

    function password_protected() {
    if ( !is_user_logged_in() ) {
    auth_redirect();
    }
    }
    add_action(‘template_redirect’, ‘password_protected’);
    add_action(‘do_feed’, ‘password_protected’);

    • Editorial Staff

      Thank you for sharing an alternative code solution, but why reinvent the wheel? There is absolutely nothing wrong with installing a plugin to do a simple task. That’s what plugins are made for. Also the author of that plugin is fairly well-reputed in the community. When we need to restrict site access by IP or logged in users, we use this plugin.

      Administrador

    • Barry

      Hi simon,

      Your code seems so simple yet it doesn’t work for me. I even check by putting a simple echo before the if statement to check if the function is being called at all and it doesn’t.

      So which add_action should i use?

    • Malc

      Simon, this plugin allows access to a whitelist of IP addresses. Not a common request – but very useful from time to time. Do you have code that could handle that function?

Deixe uma resposta

Obrigado por deixar um comentário. Lembre-se de que todos os comentários são moderados de acordo com nossos política de comentários, e seu endereço de e-mail NÃO será publicado. NÃO use palavras-chave no campo do nome. Vamos ter uma conversa pessoal e significativa.