User CP modules

Adding modules to the user control panel is possible through two hooks: userprefs_jbox and userprefs_body. jBox is the menu system used in Enano for the page toolbar, Enanium's "changes" and "site tools" menus, and the navigation menus for the user control panel. The userprefs_jbox hook is where you add your module to the menu. The userprefs_body hook is where you actually output your form.

The userprefs_body hook is a return hook, which means you need to actually return a value instead of just running a function. The variable $section tells what module of the user CP has been loaded; you must check this variable and decide if you need to output your module or not. If you echo anything out, you should return true, and if not, return false.


$plugins->attachHook('userprefs_jbox', 'myplugin_add_ucp();');
$plugins->attachHook('userprefs_body', 'return myplugin_ucp($section);');
function myplugin_add_ucp()
  // usercp_sec_profile is a localized string.
  // "My plugin options" can also be localized here.
  // The third parameter is the URL to your CP module. It doesn't have to be part of Special:Preferences;
  // you can make your own special page and call userprefs_show_menu() if you want.
  userprefs_menu_add('usercp_sec_profile', 'My plugin options', makeUrlNS('Special', 'Preferences/MyPlugin'));
function myplugin_ucp($section)
  // If we're not on the section that we want, return false.
  if ( $section != 'MyPlugin' )
    return false;
  echo '<p>Hi, this is a user CP module.</p>';
  // Tell the CP that content has been sent
  return true;

Categories: (Uncategorized)