Forum Replies Created

Viewing 15 posts - 1,861 through 1,875 (of 2,513 total)
  • Author
    Posts
  • Vladimir
    Keymaster

    You have to call current_user_can() for every role you wish to check, e.g.:

    
    if (current_user_can('role_1') || current_user_can('role_2')) {
      ...
    }
    

    This means “if current user have role_1 or current user have role_2”.

    For our code:

    
    if (!current_user_can('sales') && !current_user_can('shipping')) {
        return;
    }
    

    That is ‘do not execute code below if user does not have role ‘sales’ and user does not have role ‘shipping’.

    Vladimir
    Keymaster

    Thanks for the clarification. I missed ‘Order status’ field yesterday. Try this version. It removes dropdown list of statuses if order was refunded already and just shows “Refunded” text and removes ‘Refunded’ item from the dropdown list options in other cases:

    
    add_action('admin_head', 'hide_wc_refund_button');
    
    function hide_wc_refund_button() {
    
        global $post;
    
        if (!current_user_can('sales')) {
            return;
        }
        if (strpos($_SERVER['REQUEST_URI'], 'post.php?post=') === false) {
            return;
        }
    
        if (empty($post) || $post->post_type != 'shop_order') {
            return;
        }
    ?>
        <script>
          jQuery(function () {
                jQuery('.refund-items').hide();
                jQuery('.order_actions option[value=send_email_customer_refunded_order]').remove();
                if (jQuery('#original_post_status').val()=='wc-refunded') {
                    jQuery('#s2id_order_status').html('Refunded');
                } else {
                    jQuery('#order_status option[value=wc-refunded]').remove();
                }
            });
        </script>
        <?php
    
    }
    
    Vladimir
    Keymaster

    Try this updated version:

    
    add_action('admin_head', 'hide_wc_refund_button');
    
    function hide_wc_refund_button() {
    
        global $post;
    
        if (!current_user_can('sales')) {
            return;
        }
        if (strpos($_SERVER['REQUEST_URI'], 'post.php?post=') === false) {
            return;
        }
    
        if (empty($post) || $post->post_type != 'shop_order') {
            return;
        }
    ?>
        <script>
          jQuery(function () {
                jQuery('.refund-items').hide();
                jQuery('.order_actions option[value=send_email_customer_refunded_order]').remove();
            });
        </script>
        <?php
    
    }
    
    Vladimir
    Keymaster

    Hi,

    The only way to hide “Refunds” button from order edit form is to change HTML page CSS via JavaScript. Add code below to the active theme functions.php file or setup it as a must-use plugin. It is executed for the ‘orders-manager’ role only. Replace it with you own role ID.

    
    add_action('admin_head', 'hide_wc_refund_button');
    
    function hide_wc_refund_button() {
    
        global $post;
    
        if (!current_user_can('orders-manager')) {
            return;
        }
        if (strpos($_SERVER['REQUEST_URI'], 'post.php?post=') === false) {
            return;
        }
    
        if (empty($post) || $post->post_type != 'shop_order') {
            return;
        }
    ?>
        <script>
          jQuery().ready(function () {
                jQuery('.refund-items').hide();
            });
        </script>
        <?php
    
    }
    
    Vladimir
    Keymaster

    Hi,

    Yes, it’s possible. Input ‘Authors user ID’ list for the teacher instead of posts ID list. Use “with author user ID (comma separated)” field for that.

    in reply to: Visual Composer problems #2724
    Vladimir
    Keymaster

    Hi,

    Thanks for letting me know.

    in reply to: Screen Options #2719
    Vladimir
    Keymaster

    Hi,
    It could be suitable for admin to manage it this way. Thanks for the right direction.

    Vladimir
    Keymaster

    Hi,

    I have a recipe how to make it as an additional option to the role. It’s possible to convert the functional part to the must-use plugin for any subsite of your network.

    in reply to: Visual Composer problems #2713
    Vladimir
    Keymaster

    Hi,

    Check the browser JavaScript console for the error messages.

    Vladimir
    Keymaster

    If you wish to have more control it’s possible to integrate this code snippet with User Role Editor as the additional options for role:

    
    add_filter('ure_role_additional_options', 'add_visual_editor_only_option', 10, 1);
    function add_visual_editor_only_option() {
        $item = URE_Role_Additional_Options::create_item('visual_editor_only', esc_html__('Visual Editor Only', 'user-role-editor'), 'admin_init', 'ure_remove_text_editor');
        $items[$item->id] = $item;
        
        return $items;
    }
    
    function ure_remove_text_editor() {
      add_filter('wp_editor_settings', 'ure_editor_settings');
      add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
    }
    
    function ure_editor_settings($settings) {
      if (!current_user_can('administrator')) {
        $settings['quicktags'] = false;
      }
      
      return $settings;
    }
    
    Vladimir
    Keymaster

    You made all correctly except one thing: add as a 1st separate line to the file editor.php the tag

    
    <?php
    

    It will show to PHP interpretator where a PHP code starts.

    Vladimir
    Keymaster

    Hi Karl,

    Add this code to your active theme functions.php file or setup it as must use plugin:

    
    function my_editor_settings($settings) {
      if (!current_user_can('administrator')) {
        $settings['quicktags'] = false;
      }
      
      return $settings;
    }
    
    add_filter('wp_editor_settings', 'my_editor_settings');
    add_filter('wp_default_editor', create_function('', 'return "tinymce";'));
    
    in reply to: URE pro interferes with Events Manager #2707
    Vladimir
    Keymaster

    Hi Wolfgang,

    Look at the “Settings->User Role Editor->Additional Modules” tab. If this option “Activate “Create” capability for posts/pages/custom post types” is turned ON, role should have ‘create_events’ capability to have permission to add new events.

    Vladimir
    Keymaster

    Good. Thanks again.

    Vladimir
    Keymaster

    Thanks. Classic situation when fixing one bug I introduced another one :). It was fixed with the development version 4.28.2.b5
    Could you try it?

Viewing 15 posts - 1,861 through 1,875 (of 2,513 total)