وردپرس

Create custom tag and output the value of an acf assigned to that page


I am using contact form 7 in the footer, but it will only be displayed in the posts
Each entry has an acf that shows a field (email in this case) when editing the page
In short: on each page you have a different email using an acf

What I want is that when an email is sent in the form that it collects the email from that acf and that email is sent to the acf email

add_filter("wpcf7_special_mail_tags", function( $output, $name, $html ) {
	if ( $name === "_current_url_cs" ) {
		
		$page_id = get_the_ID();
		$extra_email = get_field('email_del_centro', $page_id);
		if ($extra_email) {
			return $extra_email;
		}
		
	}
	return $output;
}, 99, 3 );

I have created this code but if $extra_email = “text”
When sending an email it does print the “text”
but if the code is this $extra_email = get_field(’email_del_centro’, $page_id);
what prints the email when it is sent is only the tag [_current_url_cs]

  • This topic was modified 10 seconds ago by steev99.

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا