Updating users_can_register option?

I have a custom setting page, where i have a radio to Enable or Disable Registration then try to update the wpoption (users_can_register).
Screenshot:enter image description here

I’ve tried both true/false & 1/0 but it doesnt update when i saved it in my custom settings, but when i checked the checkbox in the general settings, it gets updated..

Here’s the codes im trying to use on my theme’s functions.php

if (get_option('user-reg-allow') == 'enable') {
    update_option('users_can_register',1);
}
elseif (get_option('user-reg-allow') == 'disable') {
    update_option('users_can_register',0);
}

0

Leave a Comment