I'm creating a dynamic function in WordPress that requires I create my function names dynamically.
In this instance, I need to generate a unique function name for this gravityforms code:
add_filter( 'gform_validation_message', 'change_message', 10, 2 );
function change_message( $message, $form ) {
return "<div class='validation_error'>Failed Validation - " . $form['title'] . '</div>';
}
So, I have a variable (which will change from time to time) that I want to use for my function name...
$newitem = 'new_item';
...and tried this...
add_filter( 'gform_validation_message', $newitem, 10, 2 );
function $newitem( $message, $form ) {
return "<div class='validation_error'>Failed Validation - " . $form['title'] . '</div>';
}
...but obviously that does not work. But I think you get the idea of what I am trying to achieve.
Is anything like this even possible?
Any help is appreciated.