Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Wordpress User Profile Url/Link by ID

I managed to show up the users Profile Images from the mainsite xxxxx.com/ in my bbpress forum xxxxx.com/forum/ with the following code:

<?php $user_info = get_user_by('id', $wp_query->query_vars['author']); echo get_avatar($user_info->ID, '150'); ?>

Question:

How can i get the Users Profile URL/LINK like xxxxxx.com/user/username with the same method?

Thank you so much!

like image 564
NewUser Avatar asked Dec 21 '13 22:12

NewUser


People also ask

How do I find my WordPress profile URL?

get_edit_profile_url( int $user_id, string $scheme = 'admin' ): string. Retrieves the URL to the user's profile editor.

How do I find the WordPress site for a user?

At the top right of the User Table is a search box to help find users. Enter a string in the box and click the “Search users” box. Any User that contains the search string in the Username, Name, E-mail, or Website fields will be displayed, by Role. You can then add, change, and delete those users.

How do I find user profile data in WordPress?

All you have to do is add this code to your theme's single. php file. <? php global $current_user; get_currentuserinfo(); $user_id = $current_user->ID; // You can set $user_id to any users, but this gets the current users ID.

What is Profile link in WordPress?

Profile Links are links to websites that appear on your WordPress.com profile. In the Profile Links section, click the + Add button to add a new site to your profile. You can remove any sites by clicking the X next to it: ↑ Table of Contents ↑


2 Answers

To get user's profile link like xxxxxx.com/author/username/ use the following function:

<?php get_author_posts_url( $author_id, $author_nicename ); ?>

Here is the documentation.

like image 187
Reza Mamun Avatar answered Sep 20 '22 23:09

Reza Mamun


If you want to edit a user from admin side then you can use this:

function get_admin_edit_user_link( $user_id ){

    if ( get_current_user_id() == $user_id )
       $edit_link = get_edit_profile_url( $user_id );
    else
       $edit_link = add_query_arg( 'user_id', $user_id, self_admin_url( 'user-edit.php'));

    return $edit_link;
}
like image 43
Mohan Dere Avatar answered Sep 20 '22 23:09

Mohan Dere