How can I specify the post status of an untrashed post?

I think for your purpose wp_untrash_post_status filter will be enough. Will work with single and multiple posts restore. Filters the status that a post gets assigned when it is restored from the trash (untrashed). add_filter( ‘wp_untrash_post_status’, ‘change_untrash_post_status’); function change_untrash_post_status($status){ return ‘pending’; } P.S. apply_filtershook is used to call callback functions created by us, like a … Read more

I need help using pre_get_comments to limit comments in the comments admin screen

Update In response to the new code in the updated question, you could actually use $wpdb->get_col() with a single SQL command via a JOIN clause, like so: $query = “SELECT c.comment_ID FROM $wpdb->comments c JOIN $wpdb->posts p ON p.ID = c.comment_post_ID WHERE c.user_id = $user_ID OR p.post_author = $user_ID”; $comment_ids = $wpdb->get_col( $query ); However, … Read more

Call to undefined function is_home() or any conditional tags

It’s a timing issue. This tries to call is_home() before that function exists. $my_ver = check_home(); It works in the function called by add_action because then is_home() does exist because WP has fully loaded. If you load php files in your plugin, then you can call check_home anytime in those files. For example: define( ‘MY_PLUGIN_PATH’, … Read more

current_user_can comma list vs OR (||) list

The current_user_has_role() is not a WordPress core function, on the other hand there’s wc_current_user_has_role( $role ) in WooCommerce where $role is a string, but 3rd party plugins are general off-topic. Creating this function was closed as wontfix in this ticket: https://core.trac.wordpress.org/ticket/22624 where Andrew Nacin summarized it neatly: Roles are merely a grouping of capabilities that … Read more

How to catch wordpress post ID when it’s published

To put it briefly, WordPress hooks let you modify parameters or output of functions (filters) or execute custom code when something happens (actions). Both types of hooks usually pass one or more arguments to the callback functions that are attached to them. During a page request WordPress goes through series of steps to get the … Read more