0

I have a WordPress website where being logged in is mandatory for direct access. The website offers video posts. So the user needs to login if they wants to watch the videos. Also I have provided an iframe link for every video. The user can't use the iframe until logging into WordPress, then refreshing the page that contains the iframe in order to play the video.

My question: is there a way to bypass the login page if the video is accessed not using an iframe? Note that, all the iframe links used are to another known website inside my organization.

Here is an iframe link example:

<iframe width="400" height="250" src="https://example.com/?action=getembedcode&v=1851254" frameborder="0" allowfullscreen></iframe>

The plugin I use to force login is "Force Login".

0

You can bypass Force Login based on any condition by adding the v_forcelogin_bypass filter to your theme's functions.php file. You may also use the WordPress Conditional Tags.

For example:

/**
 * Bypass Force Login to allow for exceptions.
 *
 * @param bool $bypass Whether to disable Force Login. Default false.
 * @return bool
 */
function my_forcelogin_bypass( $bypass ) {
  if ( is_single() ) {
    $bypass = true;
  }
  return $bypass;
}
add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );

I suggest you try the following bypass method:

Method 3 – Page URL based on Query String Parameter(s) and/or Value(s)

For example:

// Allow iframe videos
if ( $_GET['action'] == 'getembedcode' && isset( $_GET['v'] ) ) {
  $bypass = true;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.