changed plugin name to cipf
This commit is contained in:
40
plugins/cipf_plugin/php/author_restriction.php
Normal file
40
plugins/cipf_plugin/php/author_restriction.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user