1

How can I not execute some <script> </script> if the user is an administrator or any specific role?

Basically I need to do something like this:

    <?php if( !User( 'Administrator', 'Editor' ) ) {        
        <script> </script>        
    } ?>
3

1 Answer 1

0

Solution, using and statement '&&' for another specific role.

Closing <?php if() : ?>, <?php else : ?> Tag with a Column : to be able to post scripts inside the Loop.

<?php
global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.

if ( ! user_can( $current_user, "administrator") && ! user_can( $current_user, "specific_role" ) )  : ?> // Check user object has not got subscriber role
    <!-- Not Administrator -->
<?php else : ?>
    <!-- Administrator -->
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.