Title: Bisakah author.php di custom?
Last modified: 14 Februari 2013

---

# Bisakah author.php di custom?

 *  [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 8 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/)
 * Sore teman2, begini saya ingin meng-custom file author.php. saya ingin layout
   yang berbeda antara administrator, author, dan contributor. bisa kah?
    saya sudah
   pakai cara dengan kode ini:
 * <?php
    if ( is_contributor ) { include (TEMPLATEPATH . ‘/contributor-layout.php’);}
   else { include (TEMPLATEPATH . ‘/authorglobal.php’); } ?>
 * tapi malah semua tampilan mengikuti layout contributor.
    adakah yang tahu caranya?
   mohon di bantu ya..
 * salam,

Melihat 15 balasan - 1 sampai 15 (dari total 15)

 *  Moderator [Bogy Harseno](https://id.wordpress.org/support/users/bogyharseno-1/)
 * (@bogyharseno-1)
 * [13 years, 8 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36197)
 * > if ( is_contributor ) { … }
 * setahu saya tdk ada fungsi “is_contributor” (cmiiw).
 * tp klo tujuannya cm skedar mau filter level user, silahkan pakai fungsi [user_can()](http://codex.wordpress.org/Function_Reference/user_can)
   atau [current_user_can()](http://codex.wordpress.org/Function_Reference/current_user_can).
 *  [Yunus](https://id.wordpress.org/support/users/amyunus/)
 * (@amyunus)
 * [13 years, 8 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36198)
 * Further information [http://codex.wordpress.org/Roles_and_Capabilities](http://codex.wordpress.org/Roles_and_Capabilities)
 *  Pencetus Utas [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36199)
 * [@bogy](https://id.wordpress.org/support/users/bogy/) & [@amyunus](https://id.wordpress.org/support/users/amyunus/):
   Saya sudah coba seperti ini tp malah mengikuti layout global semua
 * <?php
    if ( current_user_can(‘contributor’) ) { include (TEMPLATEPATH . ‘/contributor-
   layout.php’); } else if ( current_user_can(‘subscriber’) ) { include (TEMPLATEPATH.‘/
   subscriber-layout.php’); } else { include (TEMPLATEPATH . ‘/authorglobal.php’);}?
   >
 * gimana ya pak caranya biar bisa tampilan layoutnya berbeda?
    Terima kasih.
 *  [Yunus](https://id.wordpress.org/support/users/amyunus/)
 * (@amyunus)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36200)
 *     ```
       <?php
          // is he a contributor? if not he is a subscriber
          if ( current_user_can('delete_posts') ) { include (TEMPLATEPATH . '/contributor-layout.php'); }
          else { include (TEMPLATEPATH . '/authorglobal.php'); }
       ?>
       ```
   
 * Just a suggestion, use [`get_query_template()`](http://codex.wordpress.org/Function_Reference/get_query_template)
   rather than `TEMPLATEPATH`.
 *  Pencetus Utas [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36201)
 * [@amyunus](https://id.wordpress.org/support/users/amyunus/): sudah saya coba 
   seperti saran pak yunus, tapi tetap tidak tampil seperti yang saya inginkan.
   
   situasi yang sekarang ini adalah: contributor-layout.php tampil jika sudah login(
   tapi ini tidak hanya untuk contributor, yang author dan admin jg mengikuti layout
   ini), jika belum login yang berfungsi layout authorglobal.php
 * sedangkan yang saya inginkan adalah:
    jika belum login/sudah login: apabila saya
   klik link nama author maka akan tampil halaman yang layoutnya “authorglobal.php”
   jika saya klik link nama contributor maka akan tampil halaman yang layoutnya “
   contributor-layout.php” dst..
 * apakah bisa jika kondisinya seperti itu pak? mohon pencerahannya.
    Terima Kasih.
 *  [Yunus](https://id.wordpress.org/support/users/amyunus/)
 * (@amyunus)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36202)
 * Iya, seperti Pak Bogy bilang, ada dua fungsi. `user_can` dan `current_user_can`.`
   Current_user_can` digunakan untuk mengetahui status yang sedang login saat itu(
   [http://codex.wordpress.org/Function_Reference/current_user_can](http://codex.wordpress.org/Function_Reference/current_user_can)).
   Sedangkan `user_can` digunakan untuk mengetahui status user dengan passing parameter(
   [http://codex.wordpress.org/Function_Reference/user_can](http://codex.wordpress.org/Function_Reference/user_can)).
 * Nah untuk kebutuhan Elisya, sepertinya cocok menggunakan `user_can` **dengan 
   passing parameter** id user yang sedang diview ya.
 *  Pencetus Utas [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36203)
 * [@amyunus](https://id.wordpress.org/support/users/amyunus/): kira2 jika menggunakan
   user_can, code yang di gunakan seperti ini kah?
 * <?php if( user_can( [@user](https://id.wordpress.org/support/users/user/), ‘contrubutoor’)){?
   >
    | | Layout Contributor | | <php }else{?> | | Layout Author | | <?php } ?>
 *  [Yunus](https://id.wordpress.org/support/users/amyunus/)
 * (@amyunus)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36204)
 * Yap. Harusnya bisa. Just a suggestion agar more readable.
 *     ```
       <?php if( user_can ( $user_id, $contributor_role_that_subscriber_doesnt_have ) ) : ?>
   
       <!-- Layout contributor -->
   
       <?php else : ?>
   
       <!-- Layout subscriber -->
   
       <?php endif; ?>
       ```
   
 *  Pencetus Utas [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36205)
 * [@amyunus](https://id.wordpress.org/support/users/amyunus/): belum bisa pak Yunus,
   else nya tak terbaca masih mengikuti layout pertama (<!– Layout contributor –
   >).
 * function user_can() di wp-includes/capabilities.php juga saya sudah buat “true”
 * itu kira2 apalagi yang kurang ya pak?
 *  [Yunus](https://id.wordpress.org/support/users/amyunus/)
 * (@amyunus)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36206)
 * Core file jangan diubah-ubah. Harusnya cuma itu sudah cukup kok. Boleh tahu code
   yang sekarang gimana?
 *  Pencetus Utas [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36207)
 * kalau wp-includes/capabilities.php tidak saya ubah malah tidak mau jalan sama
   sekali.
    Ini code yang saya pakai, saya taruh di file author.php:
 *     ```
       <?php if ( user_can($user, 'contributor') ) {
        include("wp-content/themes/webonline/header_globalnetwork.php"); ?>
       	<div id="content">
       		<div id="menu-globalnetwork" class="clearfix"><?php include("wp-content/themes/webonline/menu-globalnetwork.php"); ?></div>
       		<div id="maincontent" class="clearfix">
       			<?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs();?><br>
       			 <?php
       			 if(isset($_GET['author_name'])) :
       			 $curauth = get_userdatabylogin($author_name);
       			 else :
       			 $curauth = get_userdata(intval($author));
       			 endif;
       			 ?>
       			 <h2>About: <?php echo $curauth->display_name; ?></h2>
       			 <dl>
       			 <dt>Website</dt>
       			 <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
       			 <dt>Twitter</dt>
       			 <dd><?php echo $curauth->twitter; ?></dd>
       			 <dt>Facebook</dt>
       			 <dd><?php echo $curauth->facebook; ?></dd>
       			 <dt>Email</dt>
       			 <dd><?php echo $curauth->user_email; ?></dd>
       			 <dt>Profile</dt>
       			 <dd><?php echo $curauth->user_description; ?></dd>
       			 </dl>
       			 <h2>Posts by <?php echo $curauth->display_name; ?>:</h2>
       			 <ul>
       			 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       			 <li>
       			 <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
       			 <?php the_title(); ?></a>,
       			 <?php the_time('d M Y'); ?> in <?php the_category('&');?>
       			 </li>
       			 <?php endwhile; else: ?>
       			 <p><?php _e('No posts by this author.'); ?></p>
       			 <?php endif; ?>
       		</div>
       		<?php include("wp-content/themes/webonline/sidebarglobalnetwork.php"); ?>
       	</div>
       <?php include("wp-content/themes/webonline/footerglobalnetwork.php");
         } else { ?>
       <?php get_header(); ?>
       	<div id="content">
       		<div id="menu2" class="clearfix"><?php include("wp-content/themes/webonline/menu2.php"); ?></div>
       		<div id="maincontent" class="clearfix">
       			<?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs();?><br>
       			<?php
       			if ( have_posts() )
       			the_post();
       			?>
   
       				<h1 class="page-title author"><?php printf( __( 'Author Archives: %s', 'twentyten' ), "<span class='vcard'><a class='url fn n' href='" . get_author_posts_url( get_the_author_meta( 'ID' ) ) . "' title='" . esc_attr( get_the_author() ) . "' rel='me'>" . get_the_author() . "</a></span>" ); ?></h1>
   
            <?php
       	 rewind_posts();
       	 get_template_part( 'loop', 'author' );
       	 ?>
       		</div>
       		<?php include("wp-content/themes/webonline/sidebarsingle.php"); ?>
       	</div>
       <?php get_footer(); } ?>
       ```
   
 *  [Yunus](https://id.wordpress.org/support/users/amyunus/)
 * (@amyunus)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36208)
 * Code tersebut menurut saya memiliki penempatan if else yang kurang tepat. Silakan
   dikosultasikan dengan supervisor atau rekan sejawat ya mbak. Good luck!
 *  Moderator [Bogy Harseno](https://id.wordpress.org/support/users/bogyharseno-1/)
 * (@bogyharseno-1)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36209)
 * maaf sblmnya, tampaknya dari awal sdh salah arah, mungkin lbh baik mbak(?) [elisya](http://id.forums.wordpress.org/profile/elisya)
   hub developer theme tsb sj. mudah bagi developernya utk menyelesaikan mslh spt
   ini.
 *  Pencetus Utas [elisya](https://id.wordpress.org/support/users/elisya/)
 * (@elisya)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36210)
 * [@bogy](https://id.wordpress.org/support/users/bogy/): Salahnya darimananya ya
   pak? webdev sebelumnya juga mengatakan kalau di nyerah urusan koding :D.
 *  Moderator [Bogy Harseno](https://id.wordpress.org/support/users/bogyharseno-1/)
 * (@bogyharseno-1)
 * [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36211)
 * hehe.., silahkan temukan di codex.wordpress.org 🙂

Melihat 15 balasan - 1 sampai 15 (dari total 15)

 Topik ‘Bisakah author.php di custom?’ tertutup untuk balasan baru.

## Tag

 * [costum author.php](https://id.wordpress.org/support/topic-tag/costum-author-php/)

 * Dalam: [Komunitas Pengguna](https://id.wordpress.org/support/forum/komunitas/pengguna/)
 * 15 balasan
 * 3 partisipan
 * Balasan terakhir dari: [Bogy Harseno](https://id.wordpress.org/support/users/bogyharseno-1/)
 * Aktivitas terakhir: [13 years, 7 months yang lalu](https://id.wordpress.org/support/topic/bisakah-authorphp-di-custom/#post-36211)
 * Status: belum terselesaikan

## Topik

### Topik Paling Disukai

### Topik tanpa balasan

### Topik di luar bantuan

### Topik yang terselesaikan

### Topik yang belum terselesaikan

### Semua topik
