why is unregister_setting() undefined?

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

Related posts

Leave a Reply

1 comment

  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');