The first argument of `register_activation_hook()` is the **filename including the path**, so you need `__FILE__` instead of `plugin_dir_path( __FILE__ )`: register_activation_hook( __FILE__, 'enable_user_registration' ); function enable_user_registration() { if(!get_option('users_can_register')) { update_option( 'users_can_register', '1' ); } }