Bulk post approval and publishing doesn’t work

The problem I can immediately see is, you’ve set: ‘post_status’ => ‘published’ This should be: ‘post_status’ => ‘publish’ Also, since you are only updating the post status, it’s less error prone and more appropriate to use wp_publish_post function instead of wp_update_post function. With this change, your karma_approve_all_posts() function will look like this: function karma_approve_all_posts( $posts … Read more

Suitable hook when creating, updating and deleting posts programmatically

Hooks are not for deleting or creating posts, they are kind of event listeners. For example ‘delete_post’: “Fires immediately before a post is deleted from the database.” [https://developer.wordpress.org/reference/hooks/delete_post/] You need to use the WordPress REST API: https://developer.wordpress.org/rest-api/reference/posts/ This article by Misha Rudrastyh gives a good intro: https://rudrastyh.com/wordpress/rest-api-create-delete-posts.html

Fatal error: Call to undefined function wp_cache_get after update attempt

I think W3 Total Cache or any Cache related plugin is still activate in your site. Try to de-active all plugins manually. Using Database Open Phpmyadmin Database of the website. In the table wp_options, under the option_name column (field) find the active_plugins row. Change the option_value field to: a:0:{} Using FTP or SSH In case … Read more

Update user from external script

It sounds like you are updating the user information after the form has been displayed. You need to rearrange your code so that you are updating the user information earlier, before the form is displayed. If you need help figuring out how to do that, then you need to share some more details about how … Read more