Use current_user_can instead of Administrators
-
I think it would be great to allow users that have “back-end” rights, to see the pages and not be redirected.
Looking trough the plugin options and its code, I don’t see a way to allow non-administrator users to access our page when the plugin is active (Editors, Authors and Contributors).
I believe a simple approach would be to replace this code (coming-soon-plugin.php line 130)
//if user is log-in then we check role.
if (is_user_logged_in() )
{
//get logined in user role
global $current_user;
get_currentuserinfo();
$LoggedInUserID = $current_user->ID;
$UserData = get_userdata( $LoggedInUserID );
//if user role not ‘administrator’ redirect him to message page
if($UserData->roles[0] != “administrator”)
{
if(!is_feed())
{
$file = plugin_dir_path(__FILE__).’template/coming_soon_display.php’;
include($file);
exit();
}
}
}With this code:
if( !current_user_can( ‘manage_options’ ) ) {
if(!is_feed())
{
$file = plugin_dir_path(__FILE__).’template/coming_soon_display.php’;
include($file);
exit();
}}
- The topic ‘Use current_user_can instead of Administrators’ is closed to new replies.