41 lines
666 B
PHP
41 lines
666 B
PHP
<?php
|
|
|
|
/*
|
|
* it means someone outside wp is accessing the file, in this case kill it.
|
|
*/
|
|
if (!defined('ABSPATH')) {
|
|
die('You can not access this file!');
|
|
}
|
|
|
|
|
|
|
|
|
|
function restrict_author_page_CIPF() {
|
|
if (!is_author())
|
|
return;
|
|
|
|
$can_access = false;
|
|
if (current_user_can('administrator')) {
|
|
$can_access = true;
|
|
}
|
|
else if (current_user_can('editor')) {
|
|
$can_access = true;
|
|
}
|
|
|
|
if ($can_access === true)
|
|
return;
|
|
|
|
$author_id = get_the_author_meta( 'ID' );
|
|
$current_user_id = get_current_user_id();
|
|
|
|
if ($current_user_id != $author_id) {
|
|
wp_redirect(home_url(), 301);
|
|
exit;
|
|
}
|
|
}
|
|
add_action('template_redirect', 'restrict_author_page_CIPF', 10);
|
|
|
|
|
|
|
|
?>
|