I am not very advanced in php. I have this function that prevents wp-login.php access with redirection
add_action('init','custom_login');
function custom_login(){
global $pagenow;
if( 'wp-login.php' == $pagenow && !is_user_logged_in()) {
wp_redirect('http://yoursite.com/');
exit();
}
}
from here -> Disable Or Redirect WP-login.php
which is actually redirecting and not allowing access to wp-login.php, which is the first thing i want to have, but for logging out just redirects to 'http://yoursite.com/'
What i want to add is:
1.When the user logout from front-end redirect to current page -probably i could do this with
get_permalink()
or
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect($location);
2.When the user logout from back-end redirect to home url.
-I know that i can use is_admin() to determinate the front and back -end areas, but i need a little help to make the magic :)