When user click on wordpress login it will be redirected on magento login page. After successfully login it will be redirected to wordpress site.
Add function in wp-content/themes/themefolder/functions.php
<?php
// For login page
function redirect_login_page(){
$page_viewed = basename($_SERVER['REQUEST_URI']);
$redirect_link = base64_encode($_GET['redirect_to']);
$home_url = base64_encode( site_url() );
if( $page_viewed == "wp-login.php") {
// And away they go...
$login_page = 'store url/customer/account/login/referer/'.$home_url; // Store url is your magento site url
wp_redirect($login_page);
}
// For redirection url
if($_GET['redirect_to'] != '') {
$login_page = 'store url/customer/account/login/referer/'.$redirect_link; // Store url is your magento site url
// This condition is checked for Admin user.
if( $_GET['redirect_to'] != 'website url/wp-admin/') { // website url is your website site url
wp_redirect($login_page);
}
}
}
add_action('init','redirect_login_page');
// For logout page
function redirect_logoutpage()
{
$logout_page = 'store url/customer/account/logout/'; // Store url is your magento site url
$redirect_link = base64_encode($_GET['redirect_to']);
if($_GET['loggedout'] || $_GET['action'] == 'logout') {
if( $_GET['redirect_to'] != 'website url/wp-admin/') { // website url is your website site url
wp_redirect($logout_page);
}
}
}
add_action('init','redirect_logoutpage');
?>
Add function in wp-content/themes/themefolder/functions.php
<?php
// For login page
function redirect_login_page(){
$page_viewed = basename($_SERVER['REQUEST_URI']);
$redirect_link = base64_encode($_GET['redirect_to']);
$home_url = base64_encode( site_url() );
if( $page_viewed == "wp-login.php") {
// And away they go...
$login_page = 'store url/customer/account/login/referer/'.$home_url; // Store url is your magento site url
wp_redirect($login_page);
}
// For redirection url
if($_GET['redirect_to'] != '') {
$login_page = 'store url/customer/account/login/referer/'.$redirect_link; // Store url is your magento site url
// This condition is checked for Admin user.
if( $_GET['redirect_to'] != 'website url/wp-admin/') { // website url is your website site url
wp_redirect($login_page);
}
}
}
add_action('init','redirect_login_page');
// For logout page
function redirect_logoutpage()
{
$logout_page = 'store url/customer/account/logout/'; // Store url is your magento site url
$redirect_link = base64_encode($_GET['redirect_to']);
if($_GET['loggedout'] || $_GET['action'] == 'logout') {
if( $_GET['redirect_to'] != 'website url/wp-admin/') { // website url is your website site url
wp_redirect($logout_page);
}
}
}
add_action('init','redirect_logoutpage');
?>