Skip Navigation

[Resolved] Insert Current User View Profile Link

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to insert Current User View Profile Link

Solution:
You can use WordPress standard method get_author_posts_url() to get the current user profile link.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/insert-current-user-view-profile-link/#post-614613

Relevant Documentation:

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by theW 6 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#613957
VIEW.png

Tell us what you are trying to do?

I would like the current logged in user to have a link to VIEW their profile from the account page.
Successfully, I created the EDIT Profile page and link but having a lot of trouble to insert the VIEW link.
Their Profile View page is actually the WP Author Archive.
My code looks like this:

<p>hidden link">EDIT PROFILE<br /> (GOOD)
VIEW PROFILE<br /> (WRONG)
[wpv-logout-link class="fa fa-unlock-alt"] Log Out[/wpv-logout-link]</p> (GOOD)

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-author

Is there a similar example that we can see?
Just like facebook users can edit and view their profiles.

What is the link to your site?
hidden link

#614060

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand - you want to display author archive page when user click on "VIEW PROFILE"?

Do you have your author archive link with you?

#614069

Thank you for your reply Minesh.

Yes, you understand correct but the link would change based on the Current Logged in User.

Here's an example of one url:
hidden link

So –
If User A is logged in an clicks on "View Profile"
This would be the URL:
hidden link

If User B is logged in an clicks on "View Profile"
This would be the URL:
hidden link

If User C is logged in an clicks on "View Profile"
This would be the URL:
hidden link

etc, etc...

Makes sense right?

#614071

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - what if you try to use following code:

<a href="[wpv-post-author format="url"]">VIEW PROFILE</a>
#614337

Thank you so much for proving the code Minesh.

It wouldn't work though because it links to the Profile of the Author of that page, which is the admin.

This bellow:

<a href="[wpv-post-author format="url"]">VIEW PROFILE</a>

Keeps on linking to the same URL:
hidden link
(which is wrong)

What I need it to do is link to Current Logged in user's Profile (WP Author Archive)

Just like I explain below –

If User A is logged in, and clicks on "VIEW PROFILE"
The URL link would be:
hidden link;

If User B is logged in, and clicks on "VIEW PROFILE"
The URL link would be:
hidden link;

If User C is logged in, and clicks on "VIEW PROFILE"
The URL link would be:
hidden link;

#614613

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I got it.

What if you try to use following code:

- Add following code to your current theme's functions.php file.

function func_get_author_url( $atts ) {
    global $current_user; 
    get_currentuserinfo(); 
    $author_url = get_author_posts_url( $current_user->ID);
    return $author_url;
}
add_shortcode( 'get_author_url', 'func_get_author_url' );

Try to use the shortcode like this:

<a href="[get_author_url]">VIEW PROFILE</a>
#614732

Thank you very much Minesh.
The code you provided really worked!

I had assumed this function was already a part of the ToolSet.
(Maybe that would be a good feature for the future.
Editing and Viewing Profiles with ToolSet.)

Thanks again!