• Resolved b3hr4d

    (@b3hr4d)


    hi ,
    first of all thanks for ur awesome plugin.

    i have my function work with save_post_{post-type} action :

    function set_default_category($post_ID, $post)
    {
      if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
      }
    
      // Check permissions
      if ('lesson' == $post->post_type) {
        if (!current_user_can('edit_post', $post_ID)) {
          return;
        }
      }
      $series = wp_get_post_terms($post_ID, 'series', ["fields" => "ids"])[0];
    
      //Check if category is set
      if (empty($series)) {
        return;
      }
      // Get the terms using the seris id
      $metaSeries = get_term_meta($series);
      $inst = (int) $metaSeries['instrument_select'][0];
      $gen = (int) $metaSeries['genre_select'][0];
    
      // Set the terms using the slug!
      wp_set_object_terms($post_ID, $inst, 'instrument');
      wp_set_object_terms($post_ID, $gen, 'genre');
    
    }
    
    add_action('save_post_lesson', 'set_default_category', 10, 2);

    it works on edit post page , but in quick edit it dosent work !

    whats problem?

    edit:
    mention that when i disable plugin everything works fine.

    • This topic was modified 4 years, 5 months ago by b3hr4d.
    • This topic was modified 4 years, 5 months ago by b3hr4d.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    Glad you like the plugin. Don’t forget to leave a review ?? About your question though…. it doesn’t seem related to the functionality of my plugin. What are you trying to do? What isn’t working?

    Keep in mind that save_post_$post_type fires before save_post which is where I am saving terms in RB4T.
    https://core.trac.www.ads-software.com/browser/tags/5.4/src/wp-includes/post.php#L4133

    So if you are expecting to get wp_get_post_terms() and fetch the value that you’ve selected in RB4T… it won’t have been saved yet.

    You could try running your save routing on save_post with a priority of 20 (so after mine) and checking that the post type is your custom type.

    Hope that helps.

    Thread Starter b3hr4d

    (@b3hr4d)

    omg , you are amazing !!!

    add_action('save_post', 'set_default_category', 20, 2);

    I’m trying to change terms before saving my custom post based on Series(my custom taxonomy) .

    thanks for response

    Wish u the best <3

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘issue with save post action in quick edit’ is closed to new replies.