Michelle
Michelle

Reputation: 99

Merge lines in php

Is it possible to merge these code lines?

if ( is_user_logged_in() && is_page(8171) ) {
    wp_redirect('www.abc.com');
    exit;
}

if ( is_user_logged_in() && is_page(8189) ) {
    wp_redirect('www.abc.com');
    exit;
}

Upvotes: 0

Views: 33

Answers (1)

Arccotangent
Arccotangent

Reputation: 91

Yes. You can combine the two if statements into one like so:

if (is_user_logged_in() && (is_page(8171) || is_page(8189))) {
    wp_redirect('www.abc.com');
    exit;
}

The logic is the same, it's just shorter.

Upvotes: 3

Related Questions