Hi – thanks for using Force Login!
I’m not exactly sure about this, but maybe when you click a link in Onenote or Microsoft Word – those programs are trying to open/view the web page first instead of directly the browser?
And thus you get redirected to the login screen, because WordPress doesn’t consider you logged-in until you try to visit the page directly from the browser you’ve already logged into?
It briefly says “contacting the server for information” and then opens a new tab on my browser
The only thing I can think is happening, is between clicking the link in those programs and opening the page in your browser something (the “contacting the server for information” thing) causes the site to not recognize the initial request as coming from a logged-in user and thus sends the login screen to the browser instead?
And since I don’t have control over what those programs do when hyperlinks are clicked – your users might just have to copy/paste the linked URL directly in their browsers to view the link.
Actually, I had a thought about this – you could try adding a unique query string to the hyperlinks you create in these programs and use the v_forcelogin_whitelist filter to allow visitors to view pages with that query string.
For example:
Create a link to: https://domain.com/example/?msword
Then add the following code to your theme’s functions.php:
/**
* Filter Force Login to allow exceptions for specific URLs.
*
* @return array An array of URLs. Must be absolute.
*/
function my_forcelogin_whitelist( $whitelist ) {
// whitelist URL if query string contains 'msword'
if ( isset($_GET['msword']) ) {
$whitelist[] = site_url($_SERVER['REQUEST_URI']);
}
return $whitelist;
}
add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
Reference:
Method 3 – Page URL based on Query String Parameter(s) and/or Value(s)