Add notice for when user has no access
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin
|
* @package SportsPress/Admin
|
||||||
* @version 1.6.1
|
* @version 2.0.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
@@ -45,6 +45,13 @@ class SP_Admin_Notices {
|
|||||||
add_action( 'admin_notices', array( $this, 'install_notice' ) );
|
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'] ) ) {
|
if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
|
||||||
$notices = array_diff( $notices, array( 'theme_support' ) );
|
$notices = array_diff( $notices, array( 'theme_support' ) );
|
||||||
update_option( 'sportspress_admin_notices', $notices );
|
update_option( 'sportspress_admin_notices', $notices );
|
||||||
@@ -77,6 +84,13 @@ class SP_Admin_Notices {
|
|||||||
include( 'views/html-notice-install.php' );
|
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
|
* Show the Theme Check notice
|
||||||
*/
|
*/
|
||||||
|
|||||||
6
includes/admin/views/html-notice-no-access.php
Normal file
6
includes/admin/views/html-notice-no-access.php
Normal 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>
|
||||||
Reference in New Issue
Block a user