can registration be enabled programatically?

Yes sure you can, just update the appropriate option inside your given function..

update_option( 'users_can_register', 1 );

It’s a checkbox option, so the value is 1 = on, 0 = off..

Hope that helps..

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)