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