Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

buznuts on "redirection help"

$
0
0

hello, i have entered a piece of code to my child header file that redirects a user to my news-feed page if they were still logged in, and now i have added another piece of code to it, which redirects to home page if they are not logged in, it seems to work but i have a feeling i’m going about this the wrong way! shouldn’t i use a case statement or if else instead, i done a bit of basic programming in pascal 20 years ago, and don’t have a clue any more! here is what i have:

if (is_user_logged_in() && is_front_page() ) {
wp_redirect(‘http://www.website.com/news-feed’);
exit;
}
if (!is_user_logged_in() && !is_front_page()) {
wp_redirect(‘http://www.website.com’);
exit;
}

is there a better way of writing this?

also although this works for most pages, if i go to http://www.website.com/admin or wp-admin i get the wordpress login box, i would prefer it if that also redirected to home page so admin also have to login from there. is this possible?

many thanks

Reply


Viewing all articles
Browse latest Browse all 8245

Trending Articles