revision id is one number behind – publish_post

See this- function check_values( $post_ID, $post ) { $revisions = wp_get_post_revisions( $post_ID ); $revision_ids = []; foreach ( $revisions as $revision ) { $revision_ids[] = $revision->ID; } // $revision_ids; // holds all revision ids // $revision_ids[0]; // latest revision // $revision_ids[1]; //revision just before the latest one } add_action( ‘publish_post’, ‘check_values’, 10, 2 );

Publish Post Action Not Working

wp_publish_post – Publish a post by transitioning the post status. Note: This function does not do anything except transition the post status. If you want to ensure post_name is set, use wp_update_post() instead. publish_{$custom_post_type} – publish_post is an action triggered whenever a post is published, or if it is edited and the status is changed … Read more

Do something with thumbnail image on post publish

Actually WordPress offer a good hook , You can get data from Post Published , for more you can follow this example : https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post Example of a simple update of custom field: /* Do something with the data entered */ add_action( ‘save_post’, ‘myplugin_save_postdata’ ); /* When the post is saved, saves our custom data */ … Read more

Create a new post on a specified publish date via link?

Here is the solution I came up with! In my plugin functions: <?php function ficma_inline_script() { $datedata = explode(“-“, $_POST[‘date’]); $year = $datedata[0]; $month = $datedata[1]; $day = $datedata[2]; $newdate = date(“M d, Y”, mktime(0, 0, 0, $month, $day, $year)); ?> <script type=”text/javascript”> document.getElementById(“mm”).value = “<?=$month ?>”; document.getElementById(“cur_mm”).value = “<?=$month ?>”; document.getElementById(“hidden_mm”).value = “<?=$month ?>”; … Read more

calculate values from a field and insert them into custom fields when publishing or updating post

You can achieve this using the save_post hook, this is a hook that fires once a post has been saved. Below is an example addressing what you want to achieve: function wpse253778_calculate_values( $post_id, $post ) { if ( ‘post’ !== $post->post_type ) return; $field = get_post_meta( $post_id, ‘FIELD_NAME’, true ); //get field value $new_field_value=””;//calculate new … Read more

ACF saving posts

I used the save_post_CPT() hook for doing this. I can’t remember if it sent the content the first time though: try this code: function my_project_rt_send_email( $post_id ) { if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // If this is just a revision, don’t send the email. //if ( wp_is_post_revision( $post_id ) ) // … Read more

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