I defined a working function called “firstname” that performs properly. In my second function, I want to reference it. What am I doing wrong? I know the PHP call I am using doesn’t work, but hopefully you understand what my goal is. This is all in my functions.php file of course.
// Define function to get form field values:
// Working:
function firstname(){
$firstname = $_GET["Field1"];
echo $firstname;
}
// Find and replace values:
function replace_text_wps($text) {
$text = str_replace('firstname', '<?php firstname(); ?>', $text);
$text = str_replace('tech support', '<a href="/techsupport">Tech support</a>', $text);
$text = str_replace('computers', '<a href="/computers">Computers</a>', $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
If I understood correctly what you’re trying to do, you could go with
WordPress won’t re-parse any PHP in the text after it has gone through a filter.
Also, as mrtsherman commented, you want
return $firstnamein thefirstname()function.