User current paths (user/edit & user/current/*)

Provides UID-neutral user action paths using 'current' as a placeholder that automatically resolves to the logged-in user's ID.

user_current_paths
1,775 sites
26
drupal.org
Drupal 8 Drupal 9 Drupal 10 Drupal 11

Install

Drupal 11, 10, 9, 8 v2.0.4
composer require 'drupal/user_current_paths:^2.0'

Overview

User current paths module solves a common usability problem in Drupal: creating user-agnostic links that work for any logged-in user without knowing their specific user ID. Instead of hardcoding paths like /user/123/edit, you can use /user/current/edit which automatically redirects to the appropriate user-specific path.

This is particularly useful for creating menu links, shortcuts, or navigation elements that should point to the current user's profile, edit form, or any other user-related page. The module also provides a convenient /user/edit shortcut that redirects directly to the current user's account edit form.

Additionally, the module adds an 'Edit my account' link to the user account menu, making it easier for logged-in users to access their account settings directly from the navigation.

Features

  • Provides /user/current path that redirects to the current user's profile page (/user/{uid})
  • Provides /user/current/{action} wildcard paths that redirect to any user action page (e.g., /user/current/edit → /user/{uid}/edit)
  • Provides /user/edit shortcut path that redirects to the current user's account edit form
  • Adds 'Edit my account' menu link to the user account menu for logged-in users
  • Validates paths before redirecting, returning 404 for invalid destinations
  • Works with any user-related path including those provided by contributed modules (e.g., /user/current/shortcuts)

Use Cases

Creating User Menu Shortcuts

When building a site with a user dashboard or account area, you can create menu links using /user/current paths without needing to know user IDs. This allows for generic navigation that works for all users.

Hardcoded Links in Custom Code

When developing custom modules or themes, use /user/current/* paths in links instead of dynamically generating user-specific URLs. This simplifies code and reduces the need for user context loading.

Email Templates with Account Links

Include /user/current/edit or /user/edit links in email templates. When users click these links after logging in, they'll be redirected to their own account pages.

Shortcut Integration

Users can add /user/current/* paths to their shortcuts for quick access to their own account pages without needing to know their user ID.

External System Integration

When integrating with external systems that need to link back to user-specific Drupal pages, provide /user/current/* URLs that will work for any authenticated user.

Tips

  • Use /user/current/edit instead of building dynamic user edit URLs in your code
  • The module works with any contributed module that adds user sub-pages (e.g., /user/current/orders for commerce sites)
  • The /user/edit path is a convenient shortcut when you only need to link to the edit form
  • All redirects maintain proper access control - users will see access denied if they don't have permission to view the destination

Technical Details

Troubleshooting 3
Getting 404 error when accessing /user/current/{action}

The module validates that the target path exists. If you're getting a 404, the underlying path /user/{uid}/{action} doesn't exist. Check that the action you're trying to access is a valid user route.

Anonymous users get access denied

All routes provided by this module require the user to be logged in. Anonymous users cannot use these redirect paths.

Edit my account link not appearing in menu

The link is added to the 'account' menu. Ensure this menu is being displayed in your theme and that you are logged in.

Security Notes 3
  • The module uses Drupal's path validator to ensure redirect destinations are valid internal paths
  • Access control is enforced at the destination - users cannot access pages they don't have permission to view
  • Redirects are handled securely as if the user entered the URL manually with all security checks applied