Check for user-agent then show only specified contents in Wordpress

admin

Administrator
Staff member
I have a Wordpress website and want to show a specified content to a user who have a specified User-agent. Here is what I've done:

Code:
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT']; 
if (strpos( $user_agent, 'CostumizedAgent') !== false)
{
echo "<html><body>Show Only this codes</body></html>
}
else
{
// Show normal website
}
?>

In the condition where user agent doesn't contain
Code:
CostumizedAgent
word, normal website will be shown to the user (a normal wordpress website) but if contains word
Code:
CostumizedAgent
it'll only echo a specified HTML code to the user. I use this to create a simple secretly content! (I know it's no the way it should be done :D)

So, what should I do? Which codes I have to put in
Code:
else
place? Where should I put all the codes to work? (on all pages of website)