Very new to update queries.
My WordPress installation has a table which I need to update via a cron, need to change value via update (ideally) – I know wordpress has built in wpdb for this but I cannot for the life in me work it out.
All I want to do is change values in column ‘status’ if they contain ‘unconfirmed’ to ‘subscribed’
I have a working SQL query which I can confirm in phpmyadmin:
UPDATE wp_mailpoet_subscribers SET status = REPLACE(status, 'unconfirmed','subscribed');
So I my plan is to create a php file in wordpress and then setup a cron job, I have a bunch of others in the site (I didn’t make it!) which work fine.
The code I have tried is as follows:
global $wpdb;
$wpdb->query("UPDATE wp_mailpoet_subscribers SET status = REPLACE(status, 'unconfirmed','subscribed'");
Any help why this doesn’t work would be greatly appreciated
Thanks
global $wpdb;
$wpdb->query(“UPDATE wp_mailpoet_subscribers SET status = REPLACE(status, ‘unconfirmed’,’subscribed'”);