Skip to main content
added 240 characters in body
Source Link
bosco
  • 7k
  • 3
  • 27
  • 47

ok. hereThe is_author() conditional can be used to check if the query is my own solitontargeting an author's page. but mayBy passing one or more User IDs/nicenames into it, it will check for specific author pages. So to check if the current author page is for the current user, it can be there are a better wayspassed the return value from get_current_user_id():

 <?php 
    $currenuserid = get_current_user_id();
    $author = get_queried_object();
    $author_id = $author->ID;
        if ($currenuserid == $author_id){
        echo "belongs to current user ";
        }
    else {
    echo "not belongs to current user";
    }
    ?>
if ( is_user_logged_in() && is_author( get_current_user_id() ) ){
  echo "belongs to current user ";
}
else {
  echo "not belongs to current user";
}

ok. here is my own soliton. but may be there are a better ways

 <?php 
    $currenuserid = get_current_user_id();
    $author = get_queried_object();
    $author_id = $author->ID;
        if ($currenuserid == $author_id){
        echo "belongs to current user ";
        }
    else {
    echo "not belongs to current user";
    }
    ?>

The is_author() conditional can be used to check if the query is targeting an author's page. By passing one or more User IDs/nicenames into it, it will check for specific author pages. So to check if the current author page is for the current user, it can be passed the return value from get_current_user_id():

if ( is_user_logged_in() && is_author( get_current_user_id() ) ){
  echo "belongs to current user ";
}
else {
  echo "not belongs to current user";
}
deleted 59 characters in body
Source Link

ok. here is my own soliton. but may be there are a better ways

 <?php 
    $currenuserid = get_current_user_id();
    $author = get_queried_object();
    $author_id = $author->ID;
    //echo $currenuserid;
    //echo $author_id;
        if ($currenuserid == $author_id){
        echo "belongs to current user ";
        }
    else {
    echo "not belongs to current user";
    }
    ?>

ok. here is my own soliton. but may be there are a better ways

 <?php 
    $currenuserid = get_current_user_id();
    $author = get_queried_object();
    $author_id = $author->ID;
    //echo $currenuserid;
    //echo $author_id;
        if ($currenuserid == $author_id){
        echo "belongs to current user ";
        }
    else {
    echo "not belongs to current user";
    }
    ?>

ok. here is my own soliton. but may be there are a better ways

 <?php 
    $currenuserid = get_current_user_id();
    $author = get_queried_object();
    $author_id = $author->ID;
        if ($currenuserid == $author_id){
        echo "belongs to current user ";
        }
    else {
    echo "not belongs to current user";
    }
    ?>
Source Link

ok. here is my own soliton. but may be there are a better ways

 <?php 
    $currenuserid = get_current_user_id();
    $author = get_queried_object();
    $author_id = $author->ID;
    //echo $currenuserid;
    //echo $author_id;
        if ($currenuserid == $author_id){
        echo "belongs to current user ";
        }
    else {
    echo "not belongs to current user";
    }
    ?>