Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Need edit profile link in the menu for logged in users

You can get the current user’s info by using wp_get_current_user() and then get the profile edit link by using the user's ID as following:

 function wpse_125929_login_logout( $items ) {
    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        $profile_edit_url = admin_url( 'user-edit.php?user_id=' . $current_user->ID );
        $profile_link = '<li><a href="' . $profile_edit_url . '">Edit Profile</a></li>';
        $logout_url="<li><a href="". wp_logout_url() .'">Logout</a></li>';
        $items = $items. $profile_link. $logout_url;   
    } else {
        $login_link = '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
        $items = $items. $login_link;
    }  
    return $items;
}
add_filter( 'wp_nav_menu_items', 'wpse_125929_login_logout' );

Related Posts:

  1. Is there any way to check for user login and send him to login?
  2. Logout users upon login, based on caps/role?
  3. Can someone explain what wp_session_tokens are, and what are they used for?
  4. Init action hook running late after PayPal’s return url?
  5. How to check WordPress website username and password is correct
  6. Log in from one wordpress website to another wordpress website
  7. Problems after wp_set_password() containing an apostrophe
  8. Two-step login process – Is it possible?
  9. How do I approach removing menu items on the fly based on settings in my plugin?
  10. Proper way to pass credentials in a custom login form to avoid “headers already sent”
  11. Comments do not respect display_name setting, how to make plugin to overcome this
  12. External Authentication, session_tokens not destroyed on logout
  13. Verify if user is wordpress logged in from another app since wordpress 4.0
  14. How to customize login process
  15. Display custom fields in frontside user profile
  16. wp_insert_user() function password never match
  17. Does wp_login only trigger before an user signs in into the admin panel?
  18. Is it possible to make sure that only my plugins output is shown to the enduser?
  19. Password field is empty when using wp_signon();
  20. Plugin Development for registered users
  21. Enqueue script globally
  22. WP Multisite login not working on one subsite. Possibly cookies/ history issue?
  23. How to pull user/author profile data in a plugin?
  24. First and last name fields not filled when using wp_insert_user
  25. How do I change the image from the default mysteryman in the WP Profile page
  26. Logout after clicking URL link results in “headers already sent” error
  27. Update a user profile via frontend
  28. How do I validate extra pin field on my WordPress login form page?
  29. How to redirect home page to another page after login for all user?
  30. How to share user data across multiple WordPress websites?
  31. Allowing duplicating users with same user_login and user_email
  32. How to Login a User inside a Plugin and Redirect to page?
  33. Using custom IDP with WP
  34. Hiding the WordPress login and password fields from login page
  35. redirect_to how to make it simply work with get parameter or similar?
  36. Multiple Users Logged In Causing Incorrect Account Returned
  37. Get user logged in status from within a plugin. $current_user not defined
  38. Create a Custom Login System in WordPress [closed]
  39. how can I insert a link on login page
  40. user can login from single account detail from multiple locations(computer) at the same time [closed]
  41. how to works woocommerce cart hash
  42. How to deal with different jQuery versions?
  43. WP plugin repository didn’t parse readme.txt correctly
  44. How to show multiple instances of the WP125 Widget?
  45. Restore svn trunk of my plugin repository to the initial state?
  46. “Rendering of admin template [path to template] failed”
  47. Can I attach a plugin via my add_filter callback contents?
  48. Is there any way to pass messages from a script to a redirect target in a hidden fashion?
  49. What should I pass for $needed_dirs when calling _unzip_file_pclzip (aka PclZip)?
  50. Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
  51. Custom Path for a Plugin
  52. WP 3-way voting system: On to something! Please help!
  53. Why is the expected file not being deleted?
  54. How can the_excerpt (or equivalent) be called on a category description?
  55. List categories with descriptions via plugin
  56. How to determine which capability to use?
  57. Plugin Creation: Overriding upload_max_size and post_max_size
  58. Will a plugin able to know is_user_logged_in?
  59. Plugin could not be activated because it triggered a fatal error?
  60. How to exclude “uncategorized” from custom categories widget?
  61. Problems with wierd characters and my plugin
  62. Get cat parameter from admin-ajax
  63. how to add custom fields into new & update post page?
  64. Widget instance options not showing correctly
  65. Questions about meta box: nonce and parameters available
  66. Remove Products From Category
  67. Update product prices from remote file
  68. How to add some basic inline CSS using existing plugin or theme?
  69. Serial Number from custom table not appear in woocommerce_email_before_order_table action
  70. Font size of HTML content
  71. WordPress: redirecting to the form page after form submission to admin-post.php
  72. Foreign wp_users ID in custom plugin DB table?
  73. Displaying custom content from a plugin within the active theme
  74. How to write a shopping queue line plugin with a queue button?
  75. Why does website stretch and white space on load? [duplicate]
  76. Custom Settings Plugin Save foreach checkboxes
  77. Auto hyper link text matching slugs/pages
  78. Modify custom block plugin without losing content
  79. Metabox is not displaying
  80. check_admin_referer()
  81. Downloading File via headers doesnt work
  82. get the permalink error
  83. Creating an ics calendar from custom post type
  84. Catch metabox values in Plugin
  85. wp.media Uncaught TypeError: Cannot read properties of undefined (reading ‘state’)
  86. Cannot output plugin twice with shortcode
  87. Exclude Woocommerce Product Category From Sitemap
  88. How to make an admin plugin menu page go full screen?
  89. want to show CMB2 metabox on woocommerce product data tab
  90. wp_schedule_single_event is set correctly but sometimes not fired
  91. Dynamic page generation upon purchase of a product
  92. Customise Grouped Product display in Woocommerce with custom column
  93. WordPress (pagenow link) in ajaxurl change after i change plugin language
  94. Why is $_POST empty when saving custom Meta Box?
  95. Creating posts with links from a txt file
  96. WordPress video js error this.mediaElement.play is not a function
  97. It is possible to pass $args that sent by add_settings_field() inside another function?
  98. How to Get Last ID?
  99. Change reminder email date to 14 days before
  100. Console errors in 6.0-RC1 Widget screen
Categories plugin-development Tags login, logout, plugin-development, profiles
Fixing plugin for wpdb::prepare
Code Highlighting in BlockQuote

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress