{"id":3662749,"date":"2013-04-16T08:05:31","date_gmt":"2013-04-16T08:05:31","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/function-based-on-role\/"},"modified":"2016-08-21T00:13:07","modified_gmt":"2016-08-21T00:13:07","slug":"function-based-on-role","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/function-based-on-role\/","title":{"rendered":"function based on role"},"content":{"rendered":"<p>Hi, i&#8217;m a novice to php and am trying to figure a function out.. please help me! before i go nuts \ud83d\ude09<\/p>\n<p>I have on different pages different dynamic sidebars.. now I want to add above the regular sidebar a sidebar based on user role..<\/p>\n<p>I have added following lines to my themes sidebar.php:<\/p>\n<pre><code>&lt;?php if ( current_user_can(&#039;partner&#039;) { ?&gt;\n&lt;?php dynamic_sidebar( &#039;partner&#039; ); ?&gt;\n&lt;?php endif; } ?&gt;<\/code><\/pre>\n<p>but though calling the sidebar itself works, all sidebars go blank with the if and endif lines..<\/p>\n<p>do I first need to add the ability in functions.php? I hadn&#8217;t because I thought i was calling a regular wp function..<\/p>\n<p>btw, i\u00b4m aware of the plugin &#8220;sidebar per user role&#8221; but this replaces the sidebar on all pages whcih is not what i&#8217;m looking for..<\/p>\n<p>appreciate any pointers.. thanks!<\/p>\n","protected":false},"template":"","class_list":["post-3662749","topic","type-topic","status-closed","hentry","topic-tag-current_user_can","topic-tag-functions","topic-tag-php","topic-tag-sidebar"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3662749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3662749\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=3662749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}