• I’m using this snippet to hide the admin bar from the frontend for users who don’t have the edit_posts capability (which – by default – are users with the Subscriber role).

    function swp_remove_admin_bar() {
    if ( !current_user_can( 'edit_posts' ) && !is_admin() ) {
    show_admin_bar(false);
    }
    }
    add_action( 'after_setup_theme', 'swp_remove_admin_bar' );

    It works perfectly fine in the child theme’s functions.php file. However, upon adding it as a snippet in FluentSnippets, it doesn’t work. (I did an exact cut and paste from the functions.php file.) I also tried changing the priority from the default 10 to 1 but still no go.

    A few other snippets I copied over from the child theme’s functions.php file to FluentSnippets work fine; it’s just this one that I can’t seem to get to work.

    Is this because the after_setup_theme hook fires before FluentSnippets has a chance to come into play? In that case, what could be a suitable resolution?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘This snippet hooking into after_setup_theme doesn’t seem to work’ is closed to new replies.