ACF Default Not Working
-
Based on code from ACF support, I have a function to populate an ACF category that works great on the backend, but not when I upload a product with ACF Frontend Form for Elementor. Perhaps “transition_post_status” action does not fire on ACF Frontend Form for Elementor?
Can you advise me if you have an action that I can hook to on form-submit and then make use of the same logic below to update the category?
My function:
function add_this_to_new_products( $new_status, $old_status, $post ) { global $post; if ( $post->post_type !== 'product' ) return; if ( 'publish' !== $new_status or 'publish' === $old_status ) return; $user = wp_get_current_user(); $categoryid = get_field('category_id', 'user_'.$user->ID ); if($categoryid){ //add the category here wp_set_object_terms( $post->ID, $categoryid, 'product_cat', true ); } } add_action( 'transition_post_status', 'add_this_to_new_products', 10, 3 );Thank you
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘ACF Default Not Working’ is closed to new replies.