I’m writing a plugin that will be using custom fields added by a theme.
Because of this, it would be ideal if my plugin not be able to activate should these fields not exist.
How do I go about displaying an error and forcing the activation to fail?
Code like this can do the trick.
function plugin_activation_check(){
if ( some_check_here() ) {
// this is the fail case
deactivate_plugins(basename(__FILE__)); // Deactivate ourself
wp_die("Message to user.");
}
}
register_activation_hook(__FILE__, 'plugin_activation_check');