Support

Account

Home Forums Add-ons Options Page Project Help

Unread

Project Help

  • 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)

The topic ‘Project Help’ is closed to new replies.