Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:32:34+00:00 2026-06-03T07:32:34+00:00

i am currently working on a wordpress plugin. the plugin includes a database table

  • 0

i am currently working on a wordpress plugin. the plugin includes a database table that being update every time a post is being created, edited or deleted with the data of that post. one of the columns in this table is “post_status” and i need it to be updated with the status of a post whenever it changes. right now i am using this code:

function filter_transition_post_status( $new_status, $old_status, $post ) { 
    global $post;
    global $wpdb;
    $wpdb->query(" UPDATE my_table SET post_status='$new_status' WHERE post_id=$post->ID");
}
add_action('transition_post_status', 'filter_transition_post_status', 10, 3);

the code above work fine when i change the post status within the “edit post” page. when i change the status of a post the change happens in my table as well. however, the code doesn’t work when i use the “quick edit” mode to change the status of post or bulk change multiple posts. the change does not happen in my table.
any help resolving this issue will be much appreciated.
thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:32:35+00:00Added an answer on June 3, 2026 at 7:32 am

    I found the solution. When using the “quick edit” mode to update a post the post id cannot be retrieve using the global $post like in “edit post” page but by using $_GET[‘ID’]. So in order to cover both options, “quick edit” and “edit post” I am using the function below:

    function filter_transition_post_status( $new_status, $old_status, $post ) { 
        global $wpdb;
        global $post;
        $my_id = get_post($_GET['ID']);
        is_array($my_id) ? $post_id = $my_id[ID] : $post_id = $post->ID;
        $wpdb->query(" UPDATE my_table SET post_status='$new_status' WHERE post_id=" .$post_id);
    }
    add_action('transition_post_status', 'filter_transition_post_status', 10, 3);
    

    The function checks if $my_id get anything from $_GET[ID](in “quick edit” page) and if so it is going to use it otherwise it is going to use the global $post to get the id.

    UPDATE:

    I got a much better solution than to Stephen Harris – “You do not want to reference the global $post, but the post that is given to you as one of the argument. You simply need to remove global $post”

    function wpse50651_filter_transition_post_status( $new_status, $old_status, $post ) { 
    
        global $wpdb;
    
        $wpdb->query( 
            $wpdb->prepare( 
              "UPDATE my_table SET post_status=%s WHERE post_id=%d", 
               $new_status,$post->ID
             ) 
         );
    }
    add_action('transition_post_status', 'wpse50651_filter_transition_post_status', 10, 3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom
I'm currently working on the admin section of a Wordpress plugin and I need
I'm currently working at a WordPress Plugin. It supports shortcode and creates DOM elements,
Is it possible to loop in a wordpress plugin? I've created this plugin that
I have a Wordpress site that I am currently working on and have set
I am currently working on a plugin for Wordpress involving lots of .php files.
I'm building a Wordpress site using Sencha Touch. I've created a plugin that converts
i'm currently working on a wordpress site that needs to have the option to
I am currently working on a Wordpress blog installation. Problem i am facing is
Currently working on a script to ping every host on a /24 subnet, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.