Selectively applying action based on role
Selectively applying action based on role
Selectively applying action based on role
How to load script-related styles automatically?
How to write .htaccess dynamically? [closed]
After further testing, the problem was found to be caused by another filter, posts_where, which was registered to support searching also in custom fields, and that’s why only searching is affected. Originally it generates something like this, so if the OR statement returns true (when one of the custom fields includes foo), that post will … Read more
pre_ is a terrible prefix for this because it’s going to interfere with all of the WordPress internal hooks that are prefixed with pre_. But if you want to get the name of all the actions and filters called on a certain page you can use the all hook which adds your callback to every … Read more
As long as you don’t delete your theme by ftp, but use the regular way of switching to another theme in the admin, there is a hook to use, switch_theme. It works like this: add_action(‘switch_theme’, ‘mytheme_setup_options’); function mytheme_setup_options () { delete_option(‘mytheme_option1’); delete_option(‘mytheme_option2′); } There’s a sister hook called after_switch_theme, which you could use, for instance, … Read more
Contrary to the comments… I’d say that you should use filter as in method 1 because… Message will depend on quite a few things right now, You just do a test if statement, later on message may depend on some other factors ( like maybe validating a nonce on failure giving message ‘None invalid’ ). … Read more
I haven’t tested this yet but somebody suggested this: add_action( ‘bookly_validate_custom_field’, function ( \stdClass $field, &$errors, $cart_key, \stdClass $field_info ) { // Validation by custom_field id switch ( $field->id ) { case ‘id_value’: if ( /*$invalid == */ true ) { $errors[‘custom_fields’][ $cart_key ][ $field->id ] = __( ‘Invalid’, ‘bookly’ ); } break; } }, … Read more
Check Title Unique Or Not and If not error message and dont save
You can catch specific status change by using this action hook ‘woocommerce_order_status_{status}’. It is defined in the WC_Order class. This is how you define it: /** * Executed when the status is changed to failed. * @param int $order_id * @param \WC_Order $order */ function wpdg_9291_woocommerce_order_status_failed( $order_id, $order ) { // Do something here } … Read more