Skip Navigation

[Resolved] Disable Post Expiry on Form Update

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 9 replies, has 2 voices.

Last updated by Minesh 2 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2428829

Tell us what you are trying to do?
I have option to create post by Guest user.
Post is set to Private and has set 60 minutes to Expiry and Trash
Guest user receives link to another form, where he confirm and publish with password ,,,Then post status is changed from Private to Publish.
Can you please help with code into 'cred_save_data' snippet which will remove expiration ?
Because when user confirms post it should be published without expiration.
Thanks

Is there any documentation that you are following?
Forums + Docs

Is there a similar example that we can see?
no

What is the link to your site?

#2428831

Here si snippet for publishing where I need to add expiry removal

add_action('cred_save_data','func_potvrd_anonym_inz',10,2);
function func_potvrd_anonym_inz($post_id,$form_data) {
    if ( $form_data['id']==4882 ) {
        $my_post['ID'] = $post_id;
        $my_post['post_status'] = 'publish';
        wp_update_post( $my_post );
    }
}
#2428851

I just solve this by adding

$my_post['cred_post_expiraton_time'] = '';

Thanks

#2428871

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Postmeta key "_cred_post_expiration_time", which is used to store the post-expiration date value as the timestamp.

The correct key to set post expiration time should be:

$my_post['_cred_post_expiraton_time'] = '';
#2432067

My issue is resolved now. Thank you!

#2433543

Hello,

I marked this as resolved, but I found it does not changes expiration time.
I also tried to include update_post_meta without success.
Can you help again ?
Latest code used:

add_action('cred_save_data','func_potvrd_anonym_inz',10,2);
function func_potvrd_anonym_inz($post_id,$form_data) {
    if ( $form_data['id']==4882 ) {
        $my_post['ID'] = $post_id;
        $my_post['post_status'] = 'publish';
       	$my_post['_cred_post_expiration_time'] = '';
		//update_post_meta ($post_id,'_cred_post_expiration_time','');
        wp_update_post( $my_post );
      	
    }
}
#2433551

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share details for what post you want to change the post expire time and using what form you are creating post and on what post/page you have added the form?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2435331

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I found that the test post you shared is no longer exists.

However, I found that the code snippet you added was inactive, did you deactivated that?

I've adjusted the code snipped as given under:

add_action('cred_save_data','func_potvrd_anonym_inz',10,2);
function func_potvrd_anonym_inz($post_id,$form_data) {
    if ( $form_data['id']== 4882 ) {
     
		update_post_meta($post_id,'_cred_post_expiration_time',0);
        
      	
    }
}

It should work.

Can you please let me know if it works or share new post URL which is having the post expiration date set and edit form link.

#2435367

Hello Minesh,

It was probably my blackout and I forgot when I disable snippet.
Now it works also with original code.

Sorry for waste your time and Thanks for support

M.

#2435619

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Your welcome. Thanks that we see its working as expected.

You can mark this ticket resoled 🙂