Hey guys, I need to write a PHP function that determintes wether or not a user is logged into Wordpress. If they are, I would like them to be directed to the content page. If they are not, I would like them to be directed to the page with the front-end login. How would I write that and where would I put it?
Have you checked out this redirect script: http://stackoverflow.com/questions/11238375/wordpress-redirect-user-if-not-logged-in There are also some plugins that can automate this without programming.
Try this <?php if ( is_user_logged_in() ) { ... } ?> Code (markup): http://codex.wordpress.org/Function_Reference/is_user_logged_in
in fact you can use 2 functions at one : <?php if (!is_user_logged_in()) { auth_redirect(); } ?> Code (markup): learn more about auth_redirect : http://codex.wordpress.org/Function_Reference/auth_redirect in fact with this function, we check if user is logged in, if yes so nothing to do... once logged in, he/she will be redirected to the last page they was in... Goodluck