change woocommerce product statut (draft ->publish // publish->draft) depends on the month [closed]

date(‘M’) => ‘Aug’ and date(‘m’) => 08 add_action(‘wp’, function(){ $current_month = date(‘M’); if( $current_month == ‘Aug’ ) { wp_update_post( array( ‘ID’ => “product_id”, ‘post_status’ => ‘publish’ )); } else { wp_update_post( array( ‘ID’ => “product_id”, ‘post_status’ => ‘draft’ )); } });

Workflow for attachments in WordPress

Here is how I realized a simple media workflow. Security checking and sanitizing is up to everyone. Based on WordPress version: 4.9.8 Create Attachment Post | Handle Media if (!empty($_FILES) && isset($_POST[‘postid’])) { media_handle_upload(“attachments”, $_POST[‘postid’]); } Post status pending is not possible for attachments when using media_handle_upload. For this case a filter needs to be … Read more

Force Custom Post Type Status to ‘Future’ on first Save or Publish

wp_insert_post_data filters post data just before it is inserted into the database. Documentation add_filter(‘wp_insert_post_data’, ‘schedule_post_on_publish’, ’99’); function schedule_post_on_publish($data) { $post_type = “event”; // Replace event with exact slug of your custom post type if ( $data[‘post_type’] == $post_type AND $data[‘post_status’] == ‘publish’ ) { $data[‘post_status’] = ‘future’; } return $data; } This may help.

WordPress post_status is future, manually added

Several WordPress core features, such as checking for updates and publishing scheduled post, utilize WP-Cron. The problem is likely you had no visits to your site since the time the post is scheduled to. Scheduling errors could occur if you schedule a task for 2:00PM and no page loads occur until 5:00PM. Source: “What is … Read more

Second transition_post_status hook fired instead of the first

You can user if..else condition to combine both function into one hook. add_action( ‘transition_post_status’, ‘groupqueue_to_groupcpt_and_groupcpt_to_bannedcpt’, 10, 3); function groupqueue_to_groupcpt_and_groupcpt_to_bannedcpt($new_status, $old_status, $post){ //Move to Group Post Type if (‘publish’ === $new_status && ‘groupq’ === $post->post_type ) { wp_update_post(array( ‘ID’ => $post->ID, ‘post_type’ => ‘group’ ), true ); } else if ( ‘banned’ === $new_status && (‘groupq’ … Read more

Send email with custom fields after new draft is saved or new post published

I think you need to handle post request first. You have to do this because gutenberg calls the hook twice. function transition_post_status_handler( $new_status, $old_status, $post ) { if ( defined( ‘REST_REQUEST’ ) && REST_REQUEST ) { send_mail_on_publish( $new_status, $old_status, $post ); set_transient( ‘post_status_updater_flag’, ‘done’, 10 ); } else { if ( false === get_transient( ‘post_status_updater_flag’ … Read more

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