Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Kevin, I appreciate your hard work, please consider your effort to be about making this nice plugin work with diverse wordpress custom themes. WP Debug is enabled and its not displaying conflicting errors caused by my custom buddypress theme.

    I disabled the plugin, then paste this function from an older(2014) version of wp-forced-login plugin to my function.php:

    
    function v_getUrl() {
      $url  = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
      $url .= '://' . $_SERVER['SERVER_NAME'];
      $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
      $url .= $_SERVER['REQUEST_URI'];
      return $url;
    }
    function v_forcelogin() {
      if( !is_user_logged_in() ) {
        $url = v_getUrl();
        $whitelist = apply_filters('v_forcelogin_whitelist', array());
        $redirect_url = apply_filters('v_forcelogin_redirect', $url);
        if( preg_replace('/\?.*/', '', $url) != preg_replace('/\?.*/', '', wp_login_url()) && !in_array($url, $whitelist) ) {
          wp_safe_redirect( wp_login_url( $redirect_url ), 302 ); exit();
        }
      }
    }
    add_action('init', 'v_forcelogin');
    

    This code solves the issue of redirects all pages to the login page. But the whitelist function does not exclude the register/activation pages.

    • This reply was modified 1 year, 10 months ago by uzosky.

    Thank you for your response. I tested the plugin with the WP Twenty Seventeen theme and it worked perfectly. Please, this may be asking too much, but if you have any possible solution to make this plugin work with a custom buddypress theme please share.

    Thank you Milan! It works great after following your instruction.

    Sure, I’ll definitely go pro before I launch.
    Thanks.

    Same here. This issue should be considered critical I wish it could be fixed soonest.

Viewing 4 replies - 1 through 4 (of 4 total)