• Resolved catmaniax

    (@catmaniax)


    Hello!

    Just wondering if I could shut automatically down my whole site for let’s say 9:00 to 5:00, everyday, and also have it automatically live for the remaining other hours outside of those I mentioned.

    Please let me know.
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Dave Clements

    (@thewanderingbrit)

    You cannot. However, doing so would be fairly easy. Use a conditional to check the time and call wp_die to display a message when the store is closed. You could put this function in your functionality plugin.

    Thread Starter catmaniax

    (@catmaniax)

    Unfortunately I don’t understand how to do that. Could you give me an example or do you know if there is some kind of tutorial I can read for doing that?

    Plugin Author Dave Clements

    (@thewanderingbrit)

    Something like:

    function redirect_hours() {
    	if ( date( 'H:i:s', current_time( 'timestamp' ) ) > 09:00:00 && date( 'H:i:s', current_time( 'timestamp' ) ) < 17:00:00 ) {
    		wp_die( 'Sorry, the site is closed', 'Site closed' );
    	} else {
    		return;
    	}
    }
    
    do_action( 'template_redirect', 'redirect_hours' );

    Functionality plugin: https://github.com/theukedge/functionality-plugin

    • This reply was modified 7 years, 11 months ago by Dave Clements. Reason: Added function and hook
    Thread Starter catmaniax

    (@catmaniax)

    I will try it out, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can I shut down the whole site with this?’ is closed to new replies.