Add notice for when user has no access

This commit is contained in:
Brian Miyaji
2016-06-15 12:45:19 +10:00
parent fbf6dfb390
commit c8e0833ba7
2 changed files with 21 additions and 1 deletions

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.6.1
* @version 2.0.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -45,6 +45,13 @@ class SP_Admin_Notices {
add_action( 'admin_notices', array( $this, 'install_notice' ) );
}
if ( 'post' == $screen->base ) {
$post_id = get_the_ID();
if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
add_action( 'admin_notices', array( $this, 'no_access_notice' ) );
}
}
if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
$notices = array_diff( $notices, array( 'theme_support' ) );
update_option( 'sportspress_admin_notices', $notices );
@@ -77,6 +84,13 @@ class SP_Admin_Notices {
include( 'views/html-notice-install.php' );
}
/**
* Displays a notice when the user doesn't have access to edit a post type
*/
public function no_access_notice() {
include( 'views/html-notice-no-access.php' );
}
/**
* Show the Theme Check notice
*/

View File

@@ -0,0 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<div id="message" class="error">
<p><?php _e( 'You are not allowed to edit this item.', 'sportspress' ); ?></p>
</div>