1 comment

  1. You’re right to use ‘save_post’ action hook.

    Try this:

    <?php
    
    add_action('save_post', 'some_function');
    
    function some_function($post_id)
    {
            if(get_post_type($post_id) != "VA_LISTING_PTYPE")
            return;
        $meta_value = get_post_meta( $post_id, 'featured-cat', true );
        if($meta_value != 1)
            return;
        update_post_meta($post_id, 'website', '');
        update_post_meta($post_id, 'twitter', '');
        update_post_meta($post_id, 'facebook', '');
    }
    

    if you’re on WordPress 3.7 or higher, you can use it this way:

    add_action('save_post_VA_LISTING_PTYPE', 'some_function');
    
    function some_function($post_id)
    {
        $meta_value = get_post_meta( $post_id, 'featured-cat', true );
        if($meta_value != 1)
            return;
        update_post_meta($post_id, 'website', '');
        update_post_meta($post_id, 'twitter', '');
        update_post_meta($post_id, 'facebook', '');
    }
    

    I hope it work with you.

Comments are closed.