• Resolved Enterprise Branding

    (@enterprisebranding)


    I do have one request- and that is to have an option to disable the script from running for certain user roles.

    For me- just “administrator” role I would like to disable it for.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Gijo Varghese

    (@gijo)

    Hi @enterprisebranding thanks for the feedback

    But may I know why do you want to disable it for certain roles?

    Plugin Author Gijo Varghese

    (@gijo)

    @enterprisebranding I couldn’t find a use case for this feature request. I’ll definitely consider this in the future.

    For now, you can edit the plugin’s code (flying-pages.php) and wrap the init function something like this:

    
    if( current_user_can( 'administrator' ) )
     add_action('wp_enqueue_scripts', 'flying_pages_enqueue_scripts');
    

    I’m closing the issue for now. Feel free to update in comments about the use case.

    Thread Starter Enterprise Branding

    (@enterprisebranding)

    Hi @gijo !

    Thanks for the quick reply!
    Sorry about the delay ( wp emails were going to spam 🙁 )

    I’ve tried the above and other methods alike before submitting this request. What I mean is (and I just confirmed again before this comment) that…

    if (current_user_can('administrator')) { add_action('wp_enqueue_scripts', 'flying_pages_enqueue_scripts'); }

    returns…

    Fatal error: Uncaught Error: Call to undefined function wp_get_current_user()

    I tried wrapping the condition inside function flying_pages_enqueue_scripts() but nothing worked there for me either.

    So then I submitted this request.

    The use case is fairly simple for 2 reasons.

    1. As an admin I don’t need to hover over links and trigger a full page loading.
    – Example: I am testing out my menus and when hovering I end up loading 3 page requests when I have no intention to- and do so multiple times for as long as I am developing the menus. The same goes a little for buttons and such. So I would like to disable it for the administrator role specifically.

    2. With Litespeed Cache plugin (on Litespeed server) and Beaver Builder it got a little funky in terms of showing the new cached data. Not too sure about that, but alike, in a a page builder- one like the Oxygen Builder @ https://oxygenbuilder.com – Flying Pages would load pages in the editor from the hover that are not even clickable because clicks to other pages in the editor are disabled. That issue could be the same in other page/web builders as a logical guess I think?

    So having it disabled for administrator role as a selectable option in the backend would be great.

    The code is simple and nice of Flying Pages, and I would have added it myself and submitted like a push to you, but I could not get the condition for the script to work and I couldn’t keep spending time on it. So I’ve just disabled it for now until I can look at it later.

    Plugin Author Gijo Varghese

    (@gijo)

    @enterprisebranding sorry about the code. Pls use the below one:

    
    require_once(ABSPATH.'wp-includes/pluggable.php');
    if (!current_user_can('administrator')) { add_action('wp_enqueue_scripts', 'flying_pages_enqueue_scripts'); }
    

    I got your point on use cases. I’ll add this feature in the next feature release.

    Pls try the above code and let know. Thanks 🙂

    Thread Starter Enterprise Branding

    (@enterprisebranding)

    Hi!

    Ok.

    Looks good. I did not think of requiring the pluggable.

    However, I will have to test it a bit later. I think it might need to require within the function. In my first test, but had cache/minified I did not find that Flying Scripts was included in the source code or minified.

    So I will have to check a little later on- but wanted to reply to you message.

    Plugin Author Gijo Varghese

    (@gijo)

    @enterprisebranding ok. Let me know. I tested it with LiteSpeed server and LiteSpeed cache, works fine

    Plugin Author Gijo Varghese

    (@gijo)

    @enterprisebranding This feature has been shipped in v2.1.0

    Thread Starter Enterprise Branding

    (@enterprisebranding)

    Hi!

    All works well 🙂

    Apologies about the delay.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Option to disable script for certain user roles (ie: administrator)’ is closed to new replies.