1

trying to call

unregister_setting('general','users_can_register');

so as to removed the option for allowing or dissallowing user registration (it is required in the theme, so it is set programatically) but it is returning Call to undefined function unregister_setting()...

3
  • If you unregister that option then any dependancies core code has on that option will fail (though it may not cause a problem - i'm just hesitant to say there would be no side effects). The problem is that you're probably calling that function before the file that declares the function has been included, where are you placing the code?
    – t31os
    Nov 9, 2010 at 17:26
  • will unregistering it remove it from the database?
    – Mild Fuzz
    Nov 9, 2010 at 19:32
  • Answer - No, just checked. Use 'update_option( 'users_can_register', 1 );' followed by the code in the selected answer and BOOM, the setting remains in the database, but the ability to affect it is removed.
    – Mild Fuzz
    Nov 9, 2010 at 19:46

1 Answer 1

1

That function is only available from the wp-admin section of the site. The file that contains it is only loaded as part of the wp-admin. You need to wrap it in a hook function:

function unregister_users_can_register_setting() {
    unregister_setting('general', 'users_can_register');
}
add_action('init', 'unregister_users_can_register_setting');
1
  • Probably it's possible to include the file from within the admin and call it in the frontend then.
    – hakre
    Nov 9, 2010 at 18:13

Your Answer

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

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