• Resolved Matt Cromwell

    (@webdevmattcrom)


    Hi there, I really love the simplicity and usefulness of this plugin. Thanks for all your generosity!

    I’d love to provide like a “Secret URL” that would allow friends/clients to see the whole website – bypassing the force login completely when they use a specific url parameter, or even maybe a secret url.

    1. example.com?bypass=friendsonly
    2. example.com/bypass-totally-secure-url-2456

    I’m kind of assuming this would require storing a session cookie or something to that effect. Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Matt Cromwell

    (@webdevmattcrom)

    I attempted the following, and I see the cookie present, but it’s not bypassing the login.

    /**
     * Bypass Force Login to allow for exceptions.
     *
     * @param bool $bypass Whether to disable Force Login. Default false.
     * @return bool
     */
    function bypass_cookie( $bypass ) {
    	
        // Allow URL if query string 'parameter' exists
        //if ( isset( $_GET['bypass'] ) ) {
    	//	$bypass = true;
        //}
    
        // Allow URL where 'value' is equal to query string 'parameter'
        if ( $_GET['bypass'] == 'yes') {
    		setcookie("BypassCookie", 'yes', time()+3600);  
    		//expire in 1 hour 
            $bypass = true;
        }
    	
    	if(isset($_COOKIE['BypassCookie'])){
    		$bypass = true;
    	}
    
        return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'bypass_cookie' );
    Plugin Author Kevin Vess

    (@kevinvess)

    Hi, thanks for using Force Login!

    It looks like you’re on the correct path to customizing Force Login to suit your needs. Unfortunately, I can’t help troubleshoot your custom code.

    With that being said, are you sure the cookie is being set for the entire site or just the initial page you visit with the query string? For example:

    setcookie("BypassCookie", 'yes', time()+3600, '/');
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bypass everywhere with query param’ is closed to new replies.