Last active
July 20, 2020 18:51
-
-
Save vikastyagi87/444b0ad791fd0fe47d4ff15fb48705fe to your computer and use it in GitHub Desktop.
Load js file from in wp-admin only shop manager user through functions.php file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$user = wp_get_current_user(); | |
$allowed_roles = array('shop_manager'); | |
if( array_intersect($allowed_roles, $user->roles ) ) { | |
//Load JavaScript for admin panel (wp-admin/backend) | |
add_action( 'admin_enqueue_scripts', 'hide_admin_menu_load_custom_script' ); | |
function hide_admin_menu_load_custom_script() { | |
wp_enqueue_script('custom_js', get_stylesheet_directory_uri() .'/js/custom.js', array('jquery')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment