dinamic tag based on post category
-
hi, i’m trying to send tags while registering in a form integrated with cf7.
What I see is that the tag is different based on the post category.
For example, in the SEO category, when you sign up, I want the category name to be passed to the tag, and therefore the tag to be SEO.
il codice di seguito, è quello usato per inserire i tag, e funziona perfettamenteadd_filter( 'mc4wp_integration_contact-form-7_subscriber_data', 'vts_dinamic_tag_mc4wp_cf7',10,2); function vts_dinamic_tag_mc4wp_cf7(MC4WP_MailChimp_Subscriber $subscriber, $cf7_form_id){ $tag = 'seo'; $subscriber->tags[] = $tag; return $subscriber; }
but if i try to create that field in dynamic, it doesn’t happen. nothing.
add_filter( 'mc4wp_integration_contact-form-7_subscriber_data', 'vts_dinamic_tag_mc4wp_cf7',10,2); function vts_dinamic_tag_mc4wp_cf7(MC4WP_MailChimp_Subscriber $subscriber, $cf7_form_id){ $vtsCurrentUrl = 'https://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ]; $vtsCatTag = get_the_category(url_to_postid($vtsCurrentUrl)); $tag = $vtsCatTag[0]->slug; $subscriber->tags[] = $tag; return $subscriber; }
outside of this function, I still manage to get the category name. The problem arises inside the filter.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘dinamic tag based on post category’ is closed to new replies.