Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions class/subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,16 @@ public function monitor_new_draft_post( $post_id, $form_id, $form_settings ) {
}
//phpcs:ignore
$userdata = get_userdata( get_current_user_id() );
$order_id = uniqid( rand( 10, 1000 ), false );

if ( self::has_user_error( $form_settings ) ) {
//there is some error and it needs payment
//add a uniqid to track the post easily
$order_id = uniqid( rand( 10, 1000 ), false );
update_post_meta( $post_id, '_wpuf_order_id', $order_id, true );
}

if ( $form->is_enabled_pay_per_post() || ( $form->is_enabled_force_pack() && $form->is_enabled_fallback_cost() && ! wpuf_get_user()->subscription()->has_post_count( $form_settings['post_type'] ) ) ) {
update_post_meta( $post_id, '_wpuf_order_id', $order_id, true );
update_post_meta( $post_id, '_wpuf_payment_status', 'pending' );
}
}

/**
Expand Down
9 changes: 4 additions & 5 deletions includes/class-frontend-form-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ public function draft_post() {
}
}

// if pay per post is enabled then update payment status as pending
if ( $pay_per_post ) {
update_post_meta( $post_id, '_wpuf_payment_status', 'pending' );
}

if ( ! empty( $taxonomy_vars ) ) {
$this->set_custom_taxonomy( $post_id, $taxonomy_vars );
} else {
Expand Down Expand Up @@ -431,6 +426,10 @@ public function submit_post() {
} else {
$postarr['post_status'] = $this->form_settings['edit_post_status'];
}
// handle for falback ppp
if ( 'pending' === get_post_meta( $post_id, '_wpuf_payment_status', true ) ) {
$postarr['post_status'] = 'pending';
}
} else {
if ( isset( $this->form_settings['comment_status'] ) ) {
$postarr['comment_status'] = $this->form_settings['comment_status'];
Expand Down