I need to place this code inside a function within functions.php
How do I go about doing this?
EDIT: This is in regards to an answer I received about a problem with Headers.
"isn't inside a function. So it's being called as soon as the file loads. This means all output is sent to the screen immediately This stuff should be inside a function which is then called at the right time (like the other bits)."
The problem is, I don't know how to put this code inside a function.
    add_shortcode("snap", "wpr_snap");
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
  <style type="text/css">
    #menu-dashboard, #toplevel_page_wpcf7, #menu-tools 
    {
        display:none;
    }
</style>
<?php }
add_filter(  'gettext',  'change_post_to_portfolio'  );
add_filter(  'ngettext',  'change_post_to_portfolio'  );
 
    