hi i am looking to combing to pieces of code into 1 both work but not together keep no matter what i try it keeps crashing the site
<?php
$t=date("H");
if ($t<"12")
{
echo " Have a good morning! $display_name ";
}
else if ($t<"18")
{
echo " Have a good afternoon! $display_name ";
}
else
{
echo " Have a good evening! $display_name ";
} ?>
and
<?php global $current_user; wp_get_current_user(); ?>
<?php if ( is_user_logged_in() ) {
echo 'Welcome Brother: ' . $current_user->user_login . "\n"; }
else { wp_loginout(); } ?>
other user parameters would be great to swap out
2 Answers
I can see two very obvious flaws that might be holding you back.
$t=date("H");
gives you a formatted date as a string while if ($t<"12")
and else if ($t<"18")
are trying to do maths on words.
Consider $t=(int)date("H");
(force the answer to be a whole number) with if ($t<12)
and else if ($t<18)
which at least does maths with numbers.