Is there a way to make child posts inherit parent post terms?

I haven’t tested this extensively but it does work on both Publish and Update. When a post is Published or Updated it checks if a parent is set, grabs the parent to get all the parents taxonomies, then loops through and sets the children terms as the parents terms taxonomy by taxonomy.

/** Set Child Terms to Parent Terms **/
function set_parent_terms( $post_id, $post ) {
    if ( 'publish' === $post->post_status && $post->post_parent > 0 ) {
        $parent = get_post($post->post_parent);

        if(!empty($parent)){
            $taxonomies = get_object_taxonomies( $parent->post_type );
            foreach ( (array) $taxonomies as $taxonomy ) {
                $terms = wp_get_post_terms( $parent->ID, $taxonomy );
                if ( !empty( $terms ) ) {
                    $termArr = array_map(create_function('$obj', 'return $obj->term_id;'), $terms);
                    $tmp = wp_set_object_terms( $post_id, $termArr, $taxonomy, true );
                }
            }
        }
    }
}
add_action( 'save_post', 'set_parent_terms', 100, 2 );

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