Hi Kevin, I′m progressing with the configurations of the plugin in my theme. I need your help to finish it.
When I try to log in, it redirects to login page and so on. It looks like this: https://satreks.com/login/?redirect_to=https://satreks.com/login
I added to following code:
// Custom Login URL
function my_login_page( $login_url, $redirect ) {
return site_url( ‘/login/?redirect_to=’ . $redirect );
}
add_filter( ‘login_url’, ‘my_login_page’, 10, 2 );
// Custom Registration URL
function my_registration_page( $register_url ) {
return site_url( ‘/register/’, ‘login’ );
}
add_filter( ‘register_url’, ‘my_registration_page’, 10, 1 );
/**
* Filter Force Login to allow exceptions for specific URLs.
*
* @return array An array of URLs. Must be absolute.
*/
function my_forcelogin_whitelist( $whitelist ) {
$whitelist[] = site_url( ‘/’ );
$whitelist[] = site_url( ‘/login/’ );
$whitelist[] = site_url( ‘/register/’ );
return $whitelist;
}
add_filter(‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’, 10, 1);
function custom_wp_redirect_admin_locations() {
global $wp_rewrite;
if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
return;
$admins = array(
home_url( ‘wp-admin’, ‘relative’ ),
home_url( ‘dashboard’, ‘relative’ ),
home_url( ‘admin’, ‘relative’ ),
site_url( ‘dashboard’, ‘relative’ ),
site_url( ‘admin’, ‘relative’ ),
);
if ( in_array( untrailingslashit( $_SERVER[‘REQUEST_URI’] ), $admins ) ) {
wp_redirect( admin_url() );
exit;
}
$logins = array(
home_url( ‘wp-login.php’, ‘relative’ )
);
if ( in_array( untrailingslashit( $_SERVER[‘REQUEST_URI’] ), $logins ) ) {
wp_redirect( site_url( ‘wp-login.php’, ‘login’ ) );
exit;
}
}
function remove_default_login_redirect() {
remove_action(‘template_redirect’, ‘wp_redirect_admin_locations’, 1000);
add_action( ‘template_redirect’, ‘custom_wp_redirect_admin_locations’, 1000 );
}
add_action(‘init’,’remove_default_login_redirect’);
Do you know What is missing?
thanks
Ale