Title: function based on role
Last modified: August 21, 2016

---

# function based on role

 *  [Nikki](https://wordpress.org/support/users/paradieserl/)
 * (@paradieserl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/function-based-on-role/)
 * Hi, i’m a novice to php and am trying to figure a function out.. please help 
   me! before i go nuts 😉
 * I have on different pages different dynamic sidebars.. now I want to add above
   the regular sidebar a sidebar based on user role..
 * I have added following lines to my themes sidebar.php:
 *     ```
       <?php if ( current_user_can('partner') { ?>
       <?php dynamic_sidebar( 'partner' ); ?>
       <?php endif; } ?>
       ```
   
 * but though calling the sidebar itself works, all sidebars go blank with the if
   and endif lines..
 * do I first need to add the ability in functions.php? I hadn’t because I thought
   i was calling a regular wp function..
 * btw, i´m aware of the plugin “sidebar per user role” but this replaces the sidebar
   on all pages whcih is not what i’m looking for..
 * appreciate any pointers.. thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/function-based-on-role/#post-3662927)
 * `current_user_can('partner')`. Partner? Where did that come from? Have you reviewed
   [Roles_and_Capabilities](http://codex.wordpress.org/Roles_and_Capabilities)?
 *  Thread Starter [Nikki](https://wordpress.org/support/users/paradieserl/)
 * (@paradieserl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/function-based-on-role/#post-3662934)
 * I created it with the plugin access manager.. it shows up in various areas that
   use roles, so i´m assuming it is registered properly.. i’ll try with another 
   role though to rule that out.. thanks.
 *  Thread Starter [Nikki](https://wordpress.org/support/users/paradieserl/)
 * (@paradieserl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/function-based-on-role/#post-3662937)
 * tested it is the same thing..
 * perhaps i should emphasize the mentioned code breaks the sidebar completely, 
   the regular one does not show up anymore either, so i doubt it is the role..
 * this is the regular sidebar.php of my theme which i’m trying to add to..
 *     ```
       <?php if ( pix_get_option('pix_aside_position') != 'hidden' ) { ?>
           <div class="dotted_vert hideme sidebar_<?php echo pix_get_option('pix_aside_position'); ?>_separator sidebar_separator"></div><!-- .dotted_vert -->
           <aside class="pix_column_210 align<?php echo pix_get_option('pix_aside_position'); ?>">
           	<div>
                   <hr class="first_aside">
       			<?php dynamic_sidebar( pix_selected_sidebar() ); ?>
           	</div>
           </aside>
       <?php } ?>
       ```
   
 * if i add `<?php dynamic_sidebar( 'partner' ); ?>` before `<?php dynamic_sidebar(
   pix_selected_sidebar() ); ?>` then it works (but naturally for all roles)
    as
   soon as the rest of the code is added the entire sidebar including the divider
   line (basically everything in sidebar.php) disappears..
 * is the code missing a bracket or such that causes the entire sidebar to break?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/function-based-on-role/#post-3663026)
 * Perhaps you need to post your questions in the plugin’s dedicated forum (via 
   it’s plugin page)?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘function based on role’ is closed to new replies.

## Tags

 * [current_user_can](https://wordpress.org/support/topic-tag/current_user_can/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/function-based-on-role/#post-3663026)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
