I have tried with the code bellow, but it's not working. 43 is the ID of the forum page. Also I'm trying to use is_user_logged_in()
:
function forumpage()
{
global $post;
global $wp_query;
if ($post->post_parent != 43)
{
$thePostID = $post->post_parent;
// echo 'You are not on the forum page';
}
else
{
$thePostID = $wp_query->post->ID;
// echo 'You are at the forum page';
}
}
add_action( 'init' , 'forumpage' );