# Como impedir que alguns usuários do WP possam fazer login no Discourse

**URL:** <https://meta.discourse.org/t/how-to-prevent-some-wp-users-from-being-able-to-login-to-discourse/93234>\
**Category:** WordPress\
**Created:** [Julho 26, 2018, 7:55pm UTC](https://meta.discourse.org/t/how-to-prevent-some-wp-users-from-being-able-to-login-to-discourse/93234 "2018-07-26T19:55:22Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [Dezembro 19, 2018, 5:16pm UTC](https://meta.discourse.org/t/how-to-prevent-some-wp-users-from-being-able-to-login-to-discourse/93234/8 "2018-12-19T17:16:50Z")

</div>

> [@Ryan\_Collins1](#):
>
> Should I add that code to my theme’s functions.php file?

The code can either be added to your theme’s `functions.php` file, or to a separate plugin. It would be best to use a development site to test the code before adding it to your main site.

> [@Ryan\_Collins1](#):
>
> When a member cancels, they transition in wordpress from being a “s2Member Level 1” to a “Subscriber” - should I put if ( /\* Subscriber \*/ ) { in order to make it work?

The condition will need to return `true` if you don’t want the user to be able to login to Discourse, so you’ll probably want to check that the user does _not_ have the required membership level. You’ll need to look at the s2Member documentation to find out how to do this. I’ve never used the plugin, but it looks like you can get the membership level for the current user with:

```plaintext
get_user_field( 's2member_access_level' );

```

If that is correct, the condition would be something like this. (You’ll need to test this):

```plaintext
if ( ! 1 >= get_user_field( 's2member_access_level' ) ) {
        
    }

```

> [@Ryan\_Collins1](#):
>
> If want to redirect Subscribers to a different page aside from the homepage, do I just change home\_url with a the url of my billing update page?

Yes, you can redirect the users to any page you like.

---

_[View the full topic](https://meta.discourse.org/t/how-to-prevent-some-wp-users-from-being-able-to-login-to-discourse/93234)._
