• Nikki

    (@paradieserl)


    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

    (@esmi)

    current_user_can('partner'). Partner? Where did that come from? Have you reviewed Roles_and_Capabilities?

    Thread Starter Nikki

    (@paradieserl)

    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

    (@paradieserl)

    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

    (@esmi)

    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.