Change user menu dropdown plugin slot to "sign out" only

Hello everyone,

I have a plugin with the following plugin-slot:

#
# DISABLE USER MENU
#
PLUGIN_SLOTS.add_items([
  (
    "all",
    "desktop_user_menu_slot",
    """
    {
      op: PLUGIN_OPERATIONS.Hide,
      widgetId: 'default_contents',
    }
    """
  ),
  (
    "all",
    "learning_user_menu_slot",
    """
    {
      op: PLUGIN_OPERATIONS.Hide,
      widgetId: 'default_contents',
    }
    """
  ),
  (
    "all",
    "mobile_user_menu_slot",
    """
    {
      op: PLUGIN_OPERATIONS.Hide,
      widgetId: 'default_contents',
    }
    """
  )
])

Which hides the contents of the user menu drop-down completely resulting in the following empty drop-down menu:

Is there a way to modify the user menu drop-down using plugin slots and only have the default “Sign Out” button listed which will log out the user.

1 Like

Hello @Retr0, you can follow the steps mentioned here to modify the user menu dropdown list.

this seems to have worked for me, whether or not it’s the official/recommended way to use this plugin I’m unsure

from tutormfe.hooks import PLUGIN_SLOTS

PLUGIN_SLOTS.add_items([
    (
        "all",
        "desktop_user_menu_slot",
        """
        {
          op: PLUGIN_OPERATIONS.Hide,
          widgetId: 'default_contents',
        }
        """
    ),
    (
        "all",
        "desktop_user_menu_slot",
        """
        {
          op: PLUGIN_OPERATIONS.Insert,
          widget: {
            id: 'custom_signout_link',
            type: DIRECT_PLUGIN,
            RenderWidget: () => (
              <a href="/logout">Sign Out</a>
            ),
          },
        }
        """
    ),

    (
        "all",
        "learning_user_menu_slot",
        """
        {
          op: PLUGIN_OPERATIONS.Hide,
          widgetId: 'default_contents',
        }
        """
    ),
    (
        "all",
        "learning_user_menu_slot",
        """
        {
          op: PLUGIN_OPERATIONS.Insert,
          widget: {
            id: 'custom_signout_link',
            type: DIRECT_PLUGIN,
            RenderWidget: () => (
              <a href="/logout">Sign Out</a>
            ),
          },
        }
        """
    ),

    (
        "all",
        "mobile_user_menu_slot",
        """
        {
          op: PLUGIN_OPERATIONS.Hide,
          widgetId: 'default_contents',
        }
        """
    ),
    (
        "all",
        "mobile_user_menu_slot",
        """
        {
          op: PLUGIN_OPERATIONS.Insert,
          widget: {
            id: 'custom_signout_link',
            type: DIRECT_PLUGIN,
            RenderWidget: () => (
              <a href="/logout">Sign Out</a>
            ),
          },
        }
        """
    ),
])
1 Like

Thank you for this, works like a charm!

One small detail: You need to append your LMS_URL in front of all the hrefs (e.g. http://local.openedx.io/logout) or else it will try redirect the user to the mfe “apps” subdomain (http://apps.local.openedx.io/logout) which will not logout the user since it only works under the LMS URL.

1 Like