6

I need to run a code snippet if the user registration is allowed, but I can't find a solution. How to do this?

3
  • 1
    I don't understand the question completely. If it's your own website then you can check it yourself from wp-admin and if you are trying to spam other's website then I think this is not the right place to ask such question.
    – Robert hue
    Commented Nov 8, 2014 at 7:55
  • @robert-hue I am not a hacker :)! I need to display programmatically a message when the registration is enabled.
    – Yuri
    Commented Nov 8, 2014 at 8:01
  • My apologies. I thought you are asking about 3rd party websites. I posted an answer to your question. Please check.
    – Robert hue
    Commented Nov 8, 2014 at 8:30

1 Answer 1

12

You can check it very easily with the help of get_option.

Here is a simple code for checking if user registration is allowed.

if ( get_option( 'users_can_register' ) ) {

    // Your custom code or message to display if user registration is allowed.

}

get_option( 'users_can_register' ) returns boolean true (1) or false (0).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.