امید 5 ارسال شده در دی 93 گزارش بازنشر ارسال شده در دی 93 سلاممن از این کد ها در صفحه author استفاده میکنم<?php get_header(''); $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); ?><div class="container" id="main_container"><div class="inner_content row"><div class="post-content clearfix column smaller_section"><div id="page-top"><h2 id="page-title">صفحه شخصی <?php the_author(); ?> <a href="<?php bloginfo('url') ?>/wp-admin/profile.php" style="color:#ccc;">(ویرایش)</a> <div class="author-avatar"> <?php echo get_avatar( get_the_author_meta( 'ID' ), 125 ); ?> </div></h2></div><div id="post-" class=""><div class="entry-content"> <div class="note colm"> <h4>مشخصات</h4> <p> <span style="color:#9E1424">لقب: </span><?php echo $curauth->display_name; ?><br><span style="color:#9E1424">نقش کاربر:</span><?php$user_roles = $current_user->roles;$user_role = array_shift($user_roles);if ($user_role == 'administrator') {echo 'مدیر';} elseif ($user_role == 'editor') {echo 'ویرایشگر';} elseif ($user_role == 'author') {echo 'نویسنده';} elseif ($user_role == 'contributor') {echo 'مشارکت کننده';} elseif ($user_role == 'subscriber') {echo 'مشترک';} else {echo '<strong>' . $user_role . '</strong>';}?> </p> </div> <div style="position:relative" class="note shell"> <span class="post-edit-link"> </span> </h4> <p><?php$id = get_the_author_meta('ID');$user_posts_count = get_user_posts_count($id);$user_comment_count = get_user_comment_count($id);$get_user_point = get_user_point($id);?><span style="color:#9E1424">تاریخ عضویت: </span><?php $id = get_current_user_id();$user = get_userdata($id);$user_registered = $user->user_registered;echo parsidate('j , F , Y',$datetime=$user_registered,$lang='per'); ?> <br> <span style="color:#9E1424">تعداد مطلب منتشر شده: </span> <?php echo $user_posts_count; ?> <br> <span style="color:#9E1424">تعداد دیدگاه های منتشر شده: </span> <?php echo $user_comment_count; ?> <br> <span style="color:#9E1424">امتیاز کاربر: </span> <?php echo $get_user_point; ?> </p> </div><?php if ( have_posts() ) :?><div class="note green"> <h4>آخرین مطالب ارسالی</h4> <ul> <?php while ( have_posts() ) : the_post(); ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"> <?php the_title(); ?> </a> </li> <?php endwhile; ?> </ul> </div><?php endif; ?><?php $user_i = get_current_user_id(); $args = array( 'user_id' => $user_i, 'number' => 5, 'status' => 'approve' ); $comments = get_comments($args); if(count($comments) > 0) { ?> <div class="note green"> <h4>آخرین دیدگاهای ارسالی</h4> <ul> <?php foreach ($comments as $comment) { ?> <li> <a href="<?php echo get_permalink($comment->comment_post_ID ); ?>#comment-<?php echo $comment->comment_ID; ?>"> <?php echo strip_tags($comment->comment_author); ?>: <?php echo wp_html_excerpt( $comment->comment_content, 38 ); ?></a> </li> <?php }?> </ul> </div> <?php } ?></div></div><div class="clear"></div></div><?php get_sidebar(); ?><?php get_footer(); ?>مشکلش اینکه من وارد سایت میشم با نام کاربری خودم وقتی به صفحه شخصی author/name یک کاربر دیگه میرم تعداد پست های منو نشون یادر اخرین دیدگاهای منتشر شده دیدگاهای منو نشون میده همچنین تاریخ عضویت در سایت...لطفا راهنمایی کنیدا تشکراین کدم در فاکشن قرار دادم برای تعداد پستها و دیدگاها و امتیاز کاربرfunction get_user_posts_count($user_ID){$args = array('author' => $user_ID, 'posts_per_page' => -1);$the_query = new WP_Query( $args );if ($the_query->post_count > 0){return $the_query->post_count;}else{return 0;}}function get_user_comment_count($user_ID){global $wpdb;$where = 'WHERE comment_approved = 1 AND user_id = '.$user_ID;$comment_counts = $wpdb->get_results("SELECT user_id, COUNT( * ) AS totalFROM {$wpdb->comments}{$where}GROUP BY user_id", object);if ($comment_counts[0]->total > 0 ){return $comment_counts[0]->total;}else{return 0;}}function get_user_point($user_ID) {global $wpdb;$user_posts_count = get_user_posts_count($user_ID);$user_comment_count = get_user_comment_count($user_ID);$post_point = $user_posts_count*30;$comment_point =$user_comment_count*10;$point = $post_point + $comment_point;if($point > 0) {return $point;}else {return 0;}} نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .