Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace StackExchangeWordPress;
- add_action( 'wp_loaded', __NAMESPACE__ . 'wp_loaded' );
- function wp_loaded() {
- $role = 'author';
- if( ! is_current_user_in_role( $role ) ) {
- return;
- }
- add_action( 'wp_enqueue_scripts', __NAMESPACE__ . 'wp_enqueue_scripts' );
- add_action( 'wp_footer', __NAMESPACE__ . 'wp_footer' );
- }
- function wp_footer() { ?>
- <div class="hidden or-some-other-class-that-wont-be-shown">
- <!-- Some other HTML code -->
- </div>
- <?php }
- function wp_enqueue_scripts() {
- //* Enqueue the CSS that will initially hide the hidden div
- //* Or it could be in another stylesheet already enqueued
- wp_enqueue_style( 'name-of-style', PATH_TO . 'style-name.css' );
- //* In the javascript file, pop up the hidden div
- wp_enqueue_script( 'name-of-script', PATH_TO . 'script-name.js' );
- }
- function is_current_user_in_role( $role ) {
- return in_array( $role, (array) wp_get_current_user()->roles )
- }
Add Comment
Please, Sign In to add comment