You can use the API function permalink() to get the permalink/profile URL for any user. This helps you integrate/replace author link in your theme with profile URL, or change author link in comments to profile URL.
You must define a global If you’re going to use any API function like this:
<?php
global $userpro;
?>
Now, lets get the permalink for user ID 22
<?php
$profile_url=$userpro->permalink(22);
?>
As simple as that. Now lets say that you want to show/get the permalink of logged in user dynamically and not have to enter a custom ID, you would do this:
<?php
$profile_url=$userpro->permalink(get_current_user_id());
?>
Very simple. This way you can generate profile permalink automatically for your users dynamically by using the above API method.
Note: If you want to return this permalink in comments, get_current_user_id() won’t work! You need to get the commenter ID via $comment->user_id if the commenter is an existing user.
Example:
<?php
if (isset($comment->user_id)){
$profile_url=$userpro->permalink( $comment->user_id );
}
?>
Leave A Comment?