Filter hook before create order WooCommerce

Stumbled on this looking for the same thing which I’ve now figured out (Woocommerce 3.x)… add_filter( ‘woocommerce_checkout_create_order’, ‘mbm_alter_shipping’, 10, 1 ); function mbm_alter_shipping ($order) { if ($something == $condition) { $address = array( ‘first_name’ => ‘Martin’, ‘last_name’ => ‘Stevens’, ‘company’ => ‘MBM Studio’, ’email’ => ‘[email protected]’, ‘phone’ => ‘777-777-777-777’, ‘address_1′ => ’99 Arcadia Avenue’, ‘address_2’ … Read more

Extend core block in Gutenberg

Not a real answer alert This sounds like a long term bad idea. You are modifying a core functionality with something which do not inherit any of the generated markup of the original block. Any later processing of the block might make assumption about the markup based on the block name, but the assumptions might … Read more

switch_to_blog(): Load textdomain

You could hook into the action switch_blog. You get the new blog ID as the first argument here. But loading the complete translation files here is expensive, you also have to restore the old files after that. WordPress does not use native gettext functions, but some custom code that is much slower. See #17268. The … Read more

Disable delete user

When you click on “delete”, the action ‘delete_user’ will be launched: https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin/includes/user.php#L313 After that you can check, if the user has written at least one ‘portfolio’ post. add_action(‘delete_user’, ‘sw_portfolio_check’); function sw_portfolio_check( $user_id ) { $result = new WP_Query( array( ‘author’=>$user_id, ‘post_type’=>’portfolio’, ‘posts_per_page’=>1, ) ); if ( count($result->posts) !== 0 ){ wp_die(“User has a portfolio and … Read more

What hook do I use to edit the post statuses option in admin?

You can use the filter views_edit-post (or views_edit-{custom-post-type}) to modify the available “views”: add_filter(‘views_edit-post’, ‘cyb_remove_pending_filter’ ); function cyb_remove_pending_filter( $views ) { if( isset( $views[‘pending’] ) ) { unset( $views[‘pending’] ); } return $views; } In the above filter you need inlude the user rules you want to apply. For exmple, if you want to remove … Read more

What is the earliest possible hook for safely using `is_front_page`?

The parse_query() method of the WP_Query class sets the variables on which the conditional tags are based. The parse_query hook are executed before returning from parse_query() method, variables are already set (eg. is_home, used by is_front_page()) and is_front_page() will work, but function that changes the current state can be hooked to parse_query (it’s still parse_query() … Read more

Do WordPress Core Filenames Work as Hooks?

The short answer is ‘yes’. Taken from this article the suffix of those ‘screen specific hooks’ is given by: For custom admin pages added via add_menu_page() – including settings pages – (and related functions) it is the screen ID (the value returned by add_menu_page()) For the admin page listing posts of any post type, it … Read more

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