How to restore post to pending status (no draft)

The official documentation for wp_untrash_post documents a filter for setting the status that it will use:

enter image description here

https://developer.wordpress.org/reference/functions/wp_untrash_post/

This filter can be used to return pending instead as the status.

If that’s not an option though, you could set the post status to pending after calling wp_untrash_post, it doesn’t have to happen in a single function call, e.g.

wp_untrash_post(....);

$data = [
    'ID'          => $post_id,
    'post_status' => 'pending',
];

wp_update_post( $data );

Note though that if you call just wp_update_post it will still untrash the post but none of the filters and hooks associated with untrashing will execute, which could cause issues.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)