I want to use the hook from below. The hook will run when a draft is published
function mepr_clear_cached_ids($post) {
$post_type = get_post_type($post);
if($post_type && $post_type == 'memberpressproduct') {
// Run query here.
}
}
add_action('draft_to_publish', 'mepr_clear_cached_ids');
inside the hook I want to run that query to clear the database cache of the fields on the wp_postmeta table :
DELETE FROM [prefix]_postmeta WHERE
(
meta_key LIKE '_mepr_stripe_product_id_[gateway-id]%' OR
meta_key LIKE '_mepr_stripe_plan_id_[gateway-id]%' OR
meta_key LIKE '_mepr_stripe_tax_id_[gateway-id]%' OR
meta_key LIKE '_mepr_stripe_initial_payment_product_id_[gateway-id]%' OR
meta_key LIKE '_mepr_stripe_onetime_price_id_%'
)
AND post_id IN ([memberships])
[gateway-id] - it will be replaced by the gateway id. it's a letters and numbers id. How should the correct and best syntaxis of the query from above be added inside the hook?