[Branda Pro] Maintenance page: Guest peek

7

I see on the roadmap for Branda that the following feature is coming soon:

Option to choose existing page in Coming soon/Maintenance mode so you can use a page builder to create your layout

This is a great feature to have, and it made me think of another that would be nice. Currently if I have maintenance or coming soon enabled, my client needs to have an account and be logged in to view the site “behind the curtain” if you will. If there was a way to put a password prompt on the maintenance / coming soon page that would unlock access to the site without having to log in first, that would go a long way to being able to easily show a dev site to a client.

Let me know if this is as clear as mud or if it makes sense :stuck_out_tongue:

  • Team Startup
    • Flash Drive

    Hello,

    Phil, very good idea, I have exactly the same need.
    I had imagined an access with a link https://xxx.fr/?test=yes but with the password it’s very good too. Currently I have to use the ub_get_value filter to disable the maintenance mode. If it was standard it would be much better. Moreover the ub_get_value filter is dangerous in its use because if we forget to make a return $data, we lose all the data of Branda.

    Here is my code for example:

    /*
    Disable maintenance mode when calling ?test=yes
    /!WARNING : the hook must return $data otherwise it crashes the Branda module.
    For security reasons, it might be a good idea to export the Branda config first.
    */
    add_filter( 'ub_get_value', 'test_ub_get_value',1,4);
    function test_ub_get_value($data,$module, $section, $name){
    	if($section=="mode"&&$name=="mode"&&$data!="off"){
    		if($_GET["test"]=="oui"){
    			setcookie('test', 'yes', time()+3600);//cookie valid 1h
    			wp_redirect("/",301 );//redirect to load the cookie
    		}
    		if($_COOKIE['test']=="yes"){
    			$data="off";
    		}
    	}
    	//IMPORTANT, keep this line :
    	return $data;
    }

    It doesn’t look that complicated to implement, it would be nice if the team worked on it.
    If it’s too complicated, another solution would be to add a hook especially for that, for example add_filter(‘force_guest_mode’…, it would be much better than ub_get_value.

    kind regards,

    • Phil
      • Look Up

      Team Startup thank you for the great snippet! Personally I prefer avoiding URL parameters as a means of providing access, so a password form would be more secure. However your solution is elegant, with setting the 1h cookie.

      Also, I see your validation check includes checking for a value of “oui”, et ça me fait toujours plaisir de voir l’équivalent d’un «easter egg» dans les forums anglophones :slight_smile: