Very new to PHP and I am attempting to do the next via a snippets plugin however preserve getting essential errors:
- Prohibit all non-logged in customers to house, about and pricing pages. If trying to entry different pages, redirect to "no-permission" message web page.
- If person is logged in, enable them to solely view posts on the entrance finish if they’re the publish writer. If tried, redirect to "no-permission" web page.
- Admin has full learn entry on entrance finish.
I’ve tried with plugins however nothing fairly provides me what I would like,
Any assist is far appreciated, code beneath:
add_action( 'template_redirect', 'redirect_non_permitted_users' );
perform redirect_non_permitted_users () {
$userID = get_user_id();
$authorID = get_the_author_meta(ID);
if(current_user_can('manage_options')){
}
elseif( $userID <> $authorID || ! is_user_logged_in() || ! is_front_page() || ! is_page('about') || ! is_page('pricing')){
wp_redirect('https://www.instance.com/no-permission/');
exit;
}
}