• Resolved PleasantlyOdd

    (@pleasantlyodd)


    Hello,

    I’m looking to modify the following code, which shows my headers shopping bag, to show the shopping bag only for users with the permission, “shopkeeper”.

    <?php if ($main_header_shopping_bag == true) : ?>
    <li class="shopping-bag-button" class="right-off-canvas-toggle">
        <a href="javascript:void(0)">
            <?php if ( (isset($mr_tailor_theme_options['main_header_shopping_bag_icon']['url'])) && ($mr_tailor_theme_options['main_header_shopping_bag_icon']['url'] != "") ) : ?>
            <img src="<?php echo esc_url($mr_tailor_theme_options['main_header_shopping_bag_icon']['url']); ?>">
            <?php else : ?>
            <i class="getbowtied-icon-shop"></i>
            <?php endif; ?>
            <span class="shopping_bag_items_number"><?php echo $woocommerce->cart->cart_contents_count; ?></span>
        </a>
    </li>
    <?php endif; ?>

    Could anyone help me?

Viewing 1 replies (of 1 total)
  • Thread Starter PleasantlyOdd

    (@pleasantlyodd)

    I have solved this problem, for anyone looking I used:

    <?php if( current_user_can('editor') || current_user_can('administrator') ) { ?>

    With a closing } tag.

    The full code was:

    <?php if( current_user_can('editor') || current_user_can('administrator') ) {  ?>
        <?php if ($main_header_shopping_bag == true) : ?>
        <li class="shopping-bag-button" class="right-off-canvas-toggle">
            <a href="javascript:void(0)">
                <?php if ( (isset($mr_tailor_theme_options['main_header_shopping_bag_icon']['url'])) && ($mr_tailor_theme_options['main_header_shopping_bag_icon']['url'] != "") ) : ?>
                <img src="<?php echo esc_url($mr_tailor_theme_options['main_header_shopping_bag_icon']['url']); ?>">
                <?php else : ?>
                <i class="getbowtied-icon-shop"></i>
                <?php endif; ?>
                <span class="shopping_bag_items_number"><?php echo $woocommerce->cart->cart_contents_count; ?></span>
            </a>
        </li>
        <?php endif; ?>
    <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Role Permission Check – display something for specific user types.’ is closed to new replies.