Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1048389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:26:52+00:00 2026-05-16T16:26:52+00:00

I have a WordPress website with a custom theme. I’m using custom author template

  • 0

I have a WordPress website with a custom theme. I’m using custom author template page to display a public “profile” of the user’s page. I want to show a link to the edit page (I have a template for that too) to ONLY the logged in user who is also that particular author.

I have the following code, but it shows the edit link to ALL logged in users. I don’t want users to think they can edit other authors’ profiles.

<?php global $user_id, $user_login; 
get_currentuserinfo();  
$author_id = $curauth->user_id; 

if($user_id !== '' && $author_id == $user_id){
    echo 'EDIT LINK HERE';
}

?>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:26:53+00:00Added an answer on May 16, 2026 at 4:26 pm

    You’re almost there. Don’t worry about the global variables, they’ll just mess things up. What you want is this:

    <?php
    if(get_query_var('author_name')) :
        $curauth = get_user_by('slug', get_query_var('author_name'));
    else :
        $curauth = get_userdata(get_query_var('author'));
    endif;
    
    get_currentuserinfo();
    
    if( $curauth->ID == $user_ID) {
    
        // Do your edit link work here ...
    
    }
    ?>
    

    This first loads the current author based on the query variable used to generate the author profile page. That’s how you get $curauth->ID. Then it loads up all of the standard information for the current user (see the Codex for a full list of the variables populated by get_currentuserinfo()). Then it does a simple comparison between the two values … no need to check that $user_ID has a value, because a null value for that variable won’t be equal to $curauth->ID anyway.

    FWIW I’ve tested this on WP 3.0.1 and you should be good to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a Wordpress website for multi author and want to set user
I have an existing website running in wordpress, and uses a custom headway theme.
I have a WordPress custom theme that I want to have various alternative background
i have wordpress blog in my custom built website, i am displaying some posts
Im using wordpress for my website and i have a massive amount of data
I have a wordpress website (buddypress plugin/themes). I'm using a plugin that requires access
I have a WordPress website ( abetterworldbydesign.com ) which has user-agent detection to redirect
I have a wordpress website, recently I saw too much slow loading index page.
I'm creating a custom media center wordpress website. I have created my own gallery,
I have a wordpress website, and I want to create a simple web commerce.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.