Support » Plugins » Adapt plugin based on user ID

  • This is my first attempt at adapting an admin plugin for my own purposes. I have a general grasp of php, just enough to get myself in trouble. 🙂

    What I want to do, and can’t find quite the right code, is to modify the Hello Dolly plugin so that it displays a different set of song lines (or quotes, or whatever) for the admin vs. everyone else.

    I’d be happy enough with something really simple, like “only display if user_ID == 1”. But even better would be “if user_ID == 1, display THIS; else, display THAT” And yes, I do want to use user_ID rather than current_user_can if possible — because I only want that particular user to see the “other” text, not all admins.

    I was hoping to just surround the add_action call with an if statement, but that didn’t work.

    if (get_profile('ID') == 1) {
    add_action('admin_footer', 'hello_dolly');

    I get an error now in admin:

    Parse error: syntax error, unexpected '}' in /home/********/public_html/wp/wp-content/plugins/hello.php on line 62

    And line 62 just happens to be part of the opening comments of the code, so it doesn’t tell me for sure where the error lies, but when I remove the comments I end up with line 62 being the first line of the following code:

    function hello_dolly() {
    	global $chosen;
    	echo "<p id='dolly'>$chosen

    But there is no ” } ” on that line, so take that for what it’s worth.

    Thanks in advance for any help with this “superfluous” little project.


  • The topic ‘Adapt plugin based on user ID’ is closed to new replies.