It seems to have solved by changing the two functions, by taking a different approach:
/* CHECK IF CURRENT USER IS NOT IN POST.PHP AND IN POST-NEW.PHP
AND DOWNGRADE PUBLISH POSTS IN PENDING AFTER X DAYS */
if(is_admin() ) {global $pagenow;
if( 'post.php' != $pagenow || 'post-new.php' != $pagenow) {
add_action( 'init', 'downgrade_publish_posts' );
function downgrade_publish_posts() {
$user_ID = get_current_user_id();
global $wpdb;
$daystogo = "365";
$sql =
"UPDATE {$wpdb->posts}
SET post_status="pending"
WHERE post_type="post"
AND post_status="publish"
AND post_author="$user_ID"
AND DATEDIFF(NOW(), post_date) > %d";
$wpdb->query( $wpdb->prepare( $sql, $daystogo ) );}}}
/* CHECK IF CURRENT USER IS NOT IN POST.PHP AND IN POST-NEW.PHP
AND DELETE PENDING POSTS AFTER X DAYS */
if(is_admin() ) {global $pagenow;
if( 'post.php' != $pagenow || 'post-new.php' != $pagenow) {
add_action( 'init', 'delete_pending_posts' );
function delete_pending_posts() {
$user_ID = get_current_user_id();
global $wpdb;
$daystogo = "395";
$sql =
"DELETE FROM {$wpdb->posts}
WHERE post_type="post"
AND post_status="publish"
AND post_author="$user_ID"
AND DATEDIFF(NOW(), post_date) > %d";
$wpdb->query( $wpdb->prepare( $sql, $daystogo ) );}}}
Note: Obviously in my case, I have a function which forced the publication date after pending, with the current date.
Each observation, advice, and simplification is welcome.