Ready to get started?Download WordPress


Widget Logic
[resolved] How to display a widget just for one particular admin? (4 posts)

  1. SuperCougar
    Posted 2 years ago #


    I’d like a widget to appear only when “I” am connected as an administrator.

    There are other admins on my blog and I don’t want the widget to be displayed for them or for anybody else.

    Could you please help me? I couldn’t find the correct syntax, even after consulting the conditional tags section.

    The following code works, but for all admins not just for me:


    Thanks in advance for your help.


  2. alanft
    Plugin Author

    Posted 2 years ago #

    Looks like get_currentuserinfo() (part of pluggable.php) can help. It sets the global $current_user


    so you could do eg something like

    global $current_user; get_currentuserinfo(); return($current_user->ID==X);

  3. alanft
    Plugin Author

    Posted 2 years ago #

    oh, as that function is in pluggable you'll have to delay the "Logic load" option from the default to 'after the theme' I think

  4. SuperCougar
    Posted 2 years ago #

    Hi Alanft,

    Excuse me for answering so late.

    Your solution works like a charm.

    Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic