Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter chicchera

    (@chicchera)

    I answered myself. The solution is to add an action as follows:

    /////////////////////////////////////////////////////////////
    // filter to change the status of RSS posts imported by
    // wpematico
    function chg_rss_post_status($post_id){
      // check if it is the correct type of post
      // in my case posts are added to post type rss-post
      if(get_post_type( $post_id ) == "rss-post") {
        // check if is not a revision to avoid an endless loop
        // this action works only on brand new records
        if(!wp_is_post_revision($post_id)) {
          // unhook the action so it doesn't trigger
          // an endless loop
          remove_action('save_post','chg_rss_post_status');
          // do whatever you have to do
          // in this case change the post status
          $post_changes = array(
            'ID' => $post_id,
            'post_status' => 'pending'
            );
          wp_update_post($post_changes);
          // rehook the function
          add_action('save_post','chg_rss_post_status');
        }
      }
    }
    add_action('save_post','chg_rss_post_status');
    /////////////////////////////////////////////////////////////

    The same idea can be extended to deal with automatic tags more finely tuned than the original program, by keyword contained in the title, or to change the post type.

    Hope this helps

    Thread Starter chicchera

    (@chicchera)

    forgot to tick it as solved

    Plugin Author etruel

    (@etruel)

    thanks, chicchera, very useful
    next version will include all wordpress post status

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post status’ is closed to new replies.