You are correct in assuming that it’s not sent with the $ninja_forms_field->get_field_value() or update_field_value(). You can change it fairly easily using the ‘ninja_forms_field’ WordPress filter.
Here’s the doc on the filter itself: http://wpninjas.com/ninja-forms/docs/ninja_forms_field/
You’ll want to return $data with a new value set for: $data[‘default_value’]. Whatever you have that variable equal to will be displayed in the Text Layout Element.
Thread Starter
M
(@imlongcat)
How can i manually fire the filter function? it works in principle but it should be executed when i have calculated something via the pre_process hook.
if that is not related enough to Ninja Forms please close the thread. you can set it to resolved nevertheless since the $data[‘default_value’] works. thanks for the quick help!
The filter is a WordPress filter. You just use the add_filter() function and your function will fire whenever the filter is triggered.
So, you do something like this inside your pre_process function:
function my_pre_process_function(){
add_filter( ‘ninja_forms_field’, ‘my_filter_function’, 10, 2 );
}
Then you’d add a function to actually do the filtering.
function my_filter_function( $data, $field_id ){
if( $field_id = 3 ){
$data[‘default_value’] = “My New Text Value”;
}
$return $data;
}
Thread Starter
M
(@imlongcat)
Works like a charm. Sorry to bother you with this stupid questions.
Thanks again! If you have Paypal i’d donate $10.
No donation necessary. We make our revenue from the sale of our extensions for Ninja Forms and are happy to assist others in getting the most out of it. 🙂
We really hope to make the Ninja Forms Core a more community driven project.