• Resolved steev99

    (@steev99)


    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 1 year, 2 months ago by steev99.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter steev99

    (@steev99)

    @takayukister

    Hello good!
    I’m doing it on a local host…
    but I just realized that it does collect the acf
    In this part, if we change the page_id to a numerical id (example: 3456/id of an entry) in the email, the email entered by here on that page is sent.

    // It doesn't work (but it should work like this)
    $extra_email = get_field('center_email', $page_id);
    // Works
    $extra_email = get_field('center_email', 3456);


    what is wrong is the variable that saves the page id

    $page_id = get_the_ID();


    In summary: I think that to solve it I only need to save the id of the page from where the email is sent in that variable.

    I have tried several ways but I have not found any solution.

    • This reply was modified 1 year, 2 months ago by steev99.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create custom tag and output the value of an acf assigned to that page’ is closed to new replies.