I have created custom page ( Resume / CV ) template for our users, to display their informations like "avatar, name, description..etc
I got the users information by using $current_user = wp_get_current_user();
each user when he visit this page he can see his informations only! But what if I need this page to be public same as author.php
, all users can see the resume/cv of each other.
So now the page URL is https://www.website.com/resume/
And i need this page to be https://www.website.com/resume/?author=id
There are any options to get the user data instead of $current_user = wp_get_current_user();
to make this page public for all!
Update 1
Resume page template
<?php
/**
* Template Name: Resume Page
*/
$user = FALSE;
if (!empty($_GET['author'])) {
$user = get_user_by('ID',$_GET['author']);
} else {
$user = wp_get_current_user();
}
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="pic"><?php echo get_avatar( $user->ID, 200 ); ?></div>
<span class="first-name"><?php echo $user->display_name; ?></span>
<span class="subtitle"><?php echo $user->profession; ?></span>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
I'm trying now to add href link inside author.php
but it always return page not found!
So how can i create link belong to the author id to be easy for anyone to see the user Resume?
<?php
if ( is_user_logged_in() ):
echo '<div class="user-resume">';
echo "<a href=\"".get_bloginfo('url')."/resume/?author=";
echo $curauth->ID;
echo "\">";
echo "See full resume";
echo "</a>";
echo "</div>";
endif;
?>
What I'm trying to do is https://www.website.com/resume/?author=id
Update 2
author.php
file
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>
<?php echo $curauth->first_name .' '. $curauth->last_name; ?>
<?php echo get_avatar( $curauth->ID, 200 ); ?>
// and so on...
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
You can check if the an author parameter is passed and query the user based on ID passed in that parameter. If no parameter is passed, it will query the current user that is logged in.
$user = FALSE;
if (!empty($_GET['author']) {
$user = get_user_by('ID',$_GET['author']);
} else {
$user = wp_get_current_user();
}
You should add more validation though to check if the ID queries a valid user or the visitor is currently logged in as a user.
UPDATE FOR UPDATE
As for the link to the current user's resume, you can do the following:
echo site_url('/resume/?author=' . get_current_user_id());