Support

Account

Home Forums Front-end Issues Only admin user loads front end css

Solving

Only admin user loads front end css

  • I have been building several front end forms and all were going great until today, when I tried to load them when logged in to an account that is not the admin.

    When I am logged in as the admin user the CSS styles load on the front end and the forms look great (and work as expected). However when I am logged in to an account that is not an admin the styles are not loaded and the forms are not displayed as they should be. They function correctly (validation) etc. Just no styles.

    I was looking at getting the pro version for a couple features to complete the project I am working on, but if the forms cannot style correctly that stops this project dead in it’s tracks.

    Any ideas as to why the styles are only loading for the admin user?

    Cheers

  • Found the issue….

    I had a code snippet that was used to remove dashicons (wp_deregister_style(‘dashicons’)) but it seems that if the dashicons are removed the css does not load.

    Could be because the fields are being used for custom post types that I have assigned dashicons to (for admin). But I don’t really think that could be it.

  • Ya… I looked at OP but I didn’t think about that. I’ve had similar issues with other things, not just ACF. Nothing like the need to load a font that has no useful purpose to make a site run.

    The ACF CSS files have the dashicon CSS as a dependency. If not included the the ACF CSS will not load.

    Are you calling acf_form_head() on every page or are you calling conditionally. If you are calling it conditionally then you could de-register the style when not calling acf_form_head().

  • Thanks for the reply John,

    I am loading the acf_form_head only when needed. Might be an odd way to do it, but I am using the template_include filter to run the function when my $wp_query->query conditions are met.

    I guess I could re-add the dashicons there.

    Thanks

  • I would do

    
    if (your condtions met) {
      acf_form_head();
    } else {
      wp_deregister_style('dashicons'):
    }
    

    This is something I’ve been dealing with with all kinds of things, not just dashicons. Loading fonts is a suck on site speed as is loading anything with for ACF if there are not forms on the page.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.