Support

Account

Home Forums Add-ons Options Page Project Help

Unread

Project Help

    • mcneese

    • January 28, 2020 at 4:08 am

    The option page is setup and understand how it works but I don’t know enough PHP to finish the last part using true / false fields.

    How do I trigger this action if this field (in option page) level_3_emergency value = true?

    // 302 Temp Redirect during Level 3 Emergencies
    add_action( ‘template_redirect’, function() {
    if ( is_page( 14 ) ) {
    return;
    }

    wp_redirect( esc_url_raw( home_url( ‘../index.php?page_id=14’ ) ), 302 );
    exit;
    } );

    The project –

    I’ve created 3 emergency levels – level 1 (minor) level 2 (imminent) level 3 (disaster) using true false fields. Level 1 – 2 work. If level 1 is true a top banner will appear on the home page with status message.

    If level 2 is true, the emergency CPT posts will appear in the top section of the page. This way users don’t have to search for latest updates on what’s happening. This is usually reserved for situations where campus is about to shutdown for a tropical storm / hurricane (we’re on the gulf coast)

    Level 3 is the tough one. If level 3 is true, the entire website needs to be locked down. I’m using function to temporarily redirect traffic to a minimal home page or a status page warning students and faculty to stay away.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.