External authentication for a single page


I have looked through the previously asked questions regarding external authentication for WordPress, but I haven’t been able to really get to an answer or a combination of answers that suit the situation. I’m also somewhat green when it comes to user authentication for WordPress.

Here’s what I’m trying to do:

  • If users access a specific page, and only this specific page, force
    them to login
  • The login should redirect to our external authentication service
  • After authenticating, the user should be redirected back to the page
    and the user should be able to access the page content
  • The user should not be logged into the Admin view or have any access
    to that functionality

So basically I’m not asking that the user be logged into WordPress, just face a login challenge to access a specific page, and that login challenge should be handled by our external service.

I’d like to do this without using a third party plugin, if possible.

What I need:

An idea of where I should start.

This question had answers that seemed to provide a good frame of reference for how to force login for a single page, however, I believe the answers suggested assume that the users are authenticating to WordPress directly:

In Functions:

function my_force_login() {
global $post;

if (!is_user_logged_in()) {

On the target page:

<?php my_force_login(); ?>

Do I need to write my own plugin for this kind of authentication situation? Any clues or ideas would be extremely appreciated.

HelpImDumb 4 months 0 Answers 8 views 0

Leave an answer