Minimize WordPress Menu items for public sites

Have you ever wanted to be able to create a site that was designed to have a membership and not fear whether or not you have assigned user roles properly?

Well here is a nifty little snippet that you can add to your bp-custom.php or functions.php.  What this does (please refer to image in blue) is to take the wordpress menu shown and turn it into (please refer to the image in light grey) a very basic menu that still allows its users to create and edit their own posts.

function remove_menus () {
global $menu;
// check if the logged-in user is an adminstrator or not
if( !current_user_can('administrator') ) {
// items found on this array are those items we do not want to show the public
$restricted = array(__('Dashboard'), __('Photo Albums'), __('Profile'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
}else{
// if we reached this place, it simply means that the current user is an admin and //that we should leave the array empty since we are supposed to let the admin show //all menu items.
$restricted = array();
}

end ($menu);
// delete all menu items found in the $restricted array.
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}

}
}

add_action('admin_menu', 'remove_menus');

Well that's it... don't forget to save in either your bp-custom.php(for buddypress installations) or your functions.php (found in your theme folder.)

Related posts:



Services
  • PSD Conversion

    Need a design mockup converted into a functional WordPress theme? We can help! We specialize in slicing and dicing custom mockups into fully functional WordPress themes. The custom designed theme will also utilize all current WordPress features, like m...

  • Wordpress Websites

    Need a WordPress website? We can help! At ETN Multimedia we offer complete website solutions. We put our creativity, originality, and years of expertise to work to design the perfect WordPress website for you. Already have a WordPress website? Ca...

  • Web Design

    Web Design For the budget conscious, we offer basic, simple and static web pages coded in basic HTML, CSS and for a little dynamicity, javascripting. Please feel free to go over our web design packages. We create static web sites based on client ...

  • Web Maintenance Services

    Some corporate websites do not require a major overhaul, but instead require some kind of maintenance with regards to content and basic layout. We are more than qualified in offering regular maintenance and updating services to our clientele. Aside ...

  • Online Application Development

    Dynamism, that is the key on the today's online business, and as anybody can see, that is the future of Internet. If you want create to a dynamic online services like dating site, online shopping platform, social network platform to the World Wide ...

  • Web Development

    People often misunderstand the differences between web development and web design; these are two completely different things. Web development is in charge of the structure of the website, this is the behind the scenes operations, it is where all the c...

  • CMS Solutions

    Modern style editable web solution Having the ability to quickly and easily update your website empowers your organisation to have a highly dynamic online presence. At ETN MultiMedia, we understand that every organisation has different requirements ...

FREE CONSULTATION!
A member of our team will get in touch with you within 24 hours.

Your Name (required)

Land Phone (required)

Mobile Phone

Your Email (required)

Subject (required)

Budget (required)

Your Message

Partners