• I am using the following code. As per given instructions I have put everything in one Snippet – included rest API and deprecated whitelist etc.

    Some issues i am facing

    1. Facebook is not detecting the pages not easily accessible.
    2. Other bots are also not able to see
    3. the uri which has ?97389rfsndkjh formats are not being removed.

    Please guide.. code below

    /**
     * Bypass Force Login to allow for exceptions.
     *
     * @param bool $bypass Whether to disable Force Login. Default false.
     * @param string $visited_url The visited URL.
     * @return bool
     */
    function my_forcelogin_bypass( $bypass, $visited_url ) {
    // Allow all single posts
    //  if ( is_single() ) {
    //    $bypass = true;}
    	
    	if ( is_front_page()  ) {$bypass = true;}
    
    //  Allow any posts or pages with the tag 'public'
    //  if ( has_tag('public') ) {
    //	$bypass = true; }
     
    	// Allow the Facebook Crawler to access the site
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") !== false ) { $bypass = true;}		
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "XING-contenttabreceiver/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Xing") !== false ) {$bypass = true;}	
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "LinkedInBot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "LinkedInBot") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Gecko/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Google+") !== false ) {$bypass = true;}	
    // Allow the Google Crawler to access the site
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Googlebot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Googlebot") !== false ) {$bypass = true;}	
    // Allow the Bing Crawler to access the site
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Bingbot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Bingbot") !== false ) {$bypass = true;}	
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Twitterbot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Twitterbot") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Slurp/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Slurp") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "DuckDuckBot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "DuckDuckBot") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Baiduspider/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Baiduspider") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "YandexBot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "YandexBot") !== false ) {$bypass = true;}	
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Exabot/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Exabot") !== false ) {$bypass = true;}	
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "ia_archiver/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "ia_archiver") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "Google/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Google") !== false ) {$bypass = true;}	
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "SkypeUriPreview/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "SkypeUriPreview") !== false ) {$bypass = true;}
    if ( strpos($_SERVER["HTTP_USER_AGENT"], "WhatsApp/") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "WhatsApp") !== false ) {$bypass = true;}	
    
      // Allow these absolute URLs
      $allowed = array(
    	  home_url( '/contact/?v=c86ee0d9d7ed' ),
    	  home_url( '/listings/?v=c86ee0d9d7ed' ),
    	  home_url( '/listing/rai/?v=c86ee0d9d7ed' ),
    	  home_url( '/listing/%e0%b4%95%e0%b5%87%e0%b4%b0%e0%b4%b3%e0%b4%a4%e0%b5%8d%e0%b4%a4%e0%b4%bf%e0%b5%bd-%e0%b4%a4%e0%b4%be%e0%b4%ae%e0%b4%b8%e0%b4%bf%e0%b4%95%e0%b5%8d%e0%b4%95%e0%b5%81%e0%b4%a8%e0%b5%8d%e0%b4%a8-%e0%b4%92/?v=c86ee0d9d7ed' ),
    	  home_url( '/listing/madan-mohan-joshi/?v=c86ee0d9d7ed' ),
    	  home_url( '/listing/avid-outdoor-enthusiast-who-loves-kerala/?v=c86ee0d9d7ed' ),
    	  home_url( '/listing/?????????-????????????-?/?v=c86ee0d9d7ed' ),
    //	  home_url( '/my-account/' ),
    //	  home_url( '/my-account/?v=c86ee0d9d7ed' ),
    //Page URL with Query String
    //	  home_url( '/my-account/lost-password/' . $_SERVER['QUERY_STRING'] ),	  
    //    home_url( '/listing/rai/' . $_SERVER['QUERY_STRING'] ),
    //	  home_url( '/page-name/?' . $_SERVER['QUERY_STRING'] ),
    //    home_url( '/page-name.php?' . $_SERVER['QUERY_STRING'] ),
    	  
    // Allow URL if query string 'parameter' exists
    //    if ( isset( $_GET['parameter'] ) ) {
    //        $bypass = true;
    //    }
    
    // Allow URL where 'value' is equal to query string 'parameter'
    //    if ( $_GET['parameter'] == 'value' ) {
    //        $bypass = true;
    //    }
    //Page URL within a Specified Directory
    // Get visited URL without query string
    //    $url_path = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
    // Allow any page URL within the specified directory
    //    if ( in_array( 'page-directory', explode( '/', $url_path ) ) ) {
          	  
    	  
      );
      if ( ! $bypass ) {
        $bypass = in_array( $visited_url, $allowed );}
      return $bypass;}
    
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass', 10, 2 );
    
    remove_filter( 'rest_authentication_errors', 'v_forcelogin_rest_access', 99 );
    
    //Page URL Regardless of Query String
    // Get visited URL without query string
     //   $url_path = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
        // Allow URL
    //    if ( '/page-name/' === $url_path ) {	
    //        $bypass = true;
    //    }
        // Allow filename URL
    //    if ( '/page-name.php' === $url_path ) {
    //        $bypass = true;
    //    }
Viewing 1 replies (of 1 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    Hi, thanks for using Force Login!

    I recommend you hire a web developer to help you customize this for your site.

    Unfortunately, I’m unable to help troubleshoot these particular customization issues. It will be difficult for me to troubleshoot your code without access to your site and the hosting environment.

    Good luck!

Viewing 1 replies (of 1 total)
  • The topic ‘Facebook and some other codes not working’ is closed to new replies.