Troubles with whitelisting admin-login
-
Hi
Thank you for your great little plugin!
I’m using it with success but have one little issue.
I would like to allow users to pass to the normal backend login screen that would be accesible with this URL.
https://bacher-trauerportal.ch/wp-adminI tried to set exceptions with the methods described in the FAQ.
This works well for the password reset pages but somehow not for the backend-login.
Could you point me in the right direction?Below is the content of my functions.php from the child theme.
*** *** *** ***
<?php
/* Custom functions code goes here. *//**
* Filter Force Login to allow exceptions for specific URLs.
*
* @param array $whitelist An array of URLs. Must be absolute.
* @return array
*/
function my_forcelogin_whitelist( $whitelist ) {
$whitelist[] = home_url( ‘/wp-admin/’ );
$whitelist[] = home_url( ‘/mein-konto/passwort-vergessen/’ );
return $whitelist;
}
add_filter( ‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’ );/**
* Bypass Force Login to allow for exceptions.
*
* @param bool $bypass Whether to disable Force Login. Default false.
* @return bool
*/
function my_forcelogin_bypass( $bypass ) {
// Get visited URL without query string
$url_path = preg_replace(‘/\?.*/’, ”, $_SERVER[‘REQUEST_URI’]);// Allow URL
if ( ‘/wp-admin/’ === $url_path ) {
$bypass = true;
}// Allow filename URL
if ( ‘/wp-admin.php’ === $url_path ) {
$bypass = true;
}// Allow URL
if ( ‘/mein-konto/passwort-vergessen/’ === $url_path ) {
$bypass = true;
}// Allow filename URL
if ( ‘/mein-konto/passwort-vergessen.php’ === $url_path ) {
$bypass = true;
}return $bypass;
}
add_filter( ‘v_forcelogin_bypass’, ‘my_forcelogin_bypass’ );// Custom Login URL
function my_login_page( $login_url, $redirect ) {
return site_url( ‘/kundenlogin/?redirect_to=’ . $redirect );
}
add_filter( ‘login_url’, ‘my_login_page’, 10, 2 );// REST-API ?ffentlich verfügbar machen
remove_filter( ‘rest_authentication_errors’, ‘v_forcelogin_rest_access’, 99 );The page I need help with: [log in to see the link]
- The topic ‘Troubles with whitelisting admin-login’ is closed to new replies.