Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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()...

share|improve this question
    
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 '10 at 17:26
    
will unregistering it remove it from the database? –  Mild Fuzz Nov 9 '10 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 '10 at 19:46
add comment

1 Answer

up vote 1 down vote accepted

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');
share|improve this answer
    
Probably it's possible to include the file from within the admin and call it in the frontend then. –  hakre Nov 9 '10 at 18:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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