You are missing the second parameter in get_page_by_title
. See get_page_by_title() reference. When you are testing without explicitly specified $output
and $post_type
, this function returns the post of type ‘page’ object by default. So you have to return $page->post_parent
for patient’s parent page ID:
add_filter('gform_field_value_parent_id', 'parent_id');
function parent_id() {
// three parameters here
$page = get_page_by_title('TESTID', 'OBJECT', 'patient');
// return patient's parent page ID
if( !is_null($page) )
return $page->post_parent;
}
P. S. It’s a good practice to enable WP_DEBUG
in wp-config.php
to see all errors and warnings during development stage. Often it helps to understand bottlenecks faster.