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]
- Checking if a file is already in the Media Library
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- Get list of scripts / styles and show file which enqueued them
- How can I track active users of my plugin? and why doesn’t WordPress.Org offer this?
- Custom attachments uploader code. Almost there!
- $wpdb->insert is changing a value
- What are the default WordPress password requirements?
- The plugin generated 80 characters of unexpected output!
- How to update/auto-update my private plugin? [duplicate]
- What’s the Right Way to get and save remote data for a Gutenberg block?
- Passing array of strings to a SQL statement in a WordPress plugin
- Add multiple shipping rates from add_rate function with custom ID
- Filter, or any way to dynamically change theme screenshot image?
- On Plugin Activation, How Do I Check for Proper Transport Mechanism?
- Show add_meta_box by selecting a specific category
- Can a plugin be used to contain all custom functions to extend other plugins
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Are block templates incompatible with serialize_blocks?
- ServerSideRender and Media Object: attributes passing image data object to php renderer even though it’s not set
- Programmatically modify an admin page UI of a WordPress site from my WordPress plugin
- Will setcookie work if there is a cache plugin installed?
- Adding settings link to plugin doesn’t work
- Check Paypal Purchase is Success or Not in Easy Digital Download Plugin
- Render content after post title in wp-admin
- Error on inserting a form value to database
- Wp_list_table search box not working for custom value from database
- Notice: Trying to get property ‘term_id’ of non-object
- javascript datatables in a plugin
- How to add user details to different tables immediately after user registration
- How to change the column label in screen options for a custom column?
- include php file if page_id matches
- captcha not working in my custom plugin
- Optimising a big WordPress site
- How do I link to a php file in my plugin directory?
- Is it possible to abort post update if specific conditions on metadata are met?
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- Category select options for plugin settings
- why do I have to use required parametres?
- Does is_admin() really provide a plugin performance improvement?
- Enqueueing common php scripts in a plugin
- plugin content on front-page only. Nowhere else
- How can I save a password securely as a settings field
- How to localize data array in plugin’s option page
- Changing permalink structure breaks link to .php file which generates files dynamically
- Decontruct serialized data array from wp_options
- $wpbd->insert_id is returning null
- Plugin Activation Causes wp_register errors
- How to get values from Tinymce visual editor popup?
- How to debug new shortcode? And how to get string from shortcode into code?
- Ajax call not working with
- plugin modal/popup integration best practice
- how to display my WordPress plugin on a chosen page?
- Sessions in plugin development?
- Is it possible to make WordPress as a RESTful app?
- List all content by post type
- Best Way to Grab Post ID from Plugin
- How to set/change another post author by custom fields or something else?
- check wp_login into a plugin
- how can a plugin return an error message on activation?
- Display months on a drop down calendar as TEXT instead of Numbers