Skip to content

Hack for working locally with APIs

martynmjones edited this page Jul 25, 2023 · 5 revisions
// Filter the WC API
add_filter( 'determine_current_user', function( $user_id ) {
	return 1;
}, 20 );
add_filter( 'woocommerce_api_check_authentication', function( $user ) {
	return new WP_User( 1 );
} );
add_filter( 'rest_authentication_errors', '__return_null', 500 );

Use Ads account without setting billing data

First, enable the connection testing with the connection test page filter.

After creating the account via Connection Test page (/wp-admin/admin.php?page=connection-test-admin-page), either visit the redirect URL (authorizes account), or click through the activation link in the received email.

On your site you'll want to have the code snippet:

add_filter(
	'woocommerce_gla_ads_billing_setup_status',
	function( $status ) {
		return 'approved';
	}
);