I have created a dynamic link button that links to Buddypress user profile. A login user that clicks on this button will be brought to user's profile. However, a guest that clicks on this button will be by default redirected to WP login page. I want a user to be redirected to my custom login page. How can I do that?
I've tried this code. It works. It redirects to my custom login page. But how can I login to WP as admin in order to go to admin dashboard? As I go to wp-login.php
, it will redirect me to my custom page in stead.
add_action('init','possibly_redirect');
function possibly_redirect(){
global $pagenow;
if( 'wp-login.php' == $pagenow ) {
wp_redirect('http://localhost/test/login/');
exit();
}
}