Page 1 of 1

Displaying plugins only for specific users?

Posted: Wed Sep 15, 2010 5:00 pm
by perlnerd
While building new plugins I'd like to be able to only make them available to specific users for testing. This would allow me to mess around with code on the live blog but not have everyone see it until it's ready.

If this is documented somewhere please point me to it. Otherwise, how might I do this?

Thanks,
Clint

Re: Displaying plugins only for specific users?

Posted: Thu Sep 16, 2010 9:56 am
by garvinhicking
Hi!

With "see it" do you mean on the frontend, or in the backend configuration? Both should be possible, but with different means. One involves something like the event_sidebarhider plugin for frontend, and for backend, you can configure "forbidden plugins" for each serendipity user group.

HTH,
Garvin

Re: Displaying plugins only for specific users?

Posted: Thu Sep 16, 2010 10:30 pm
by perlnerd
Sorry, I wasn't clear. I'm referring to sidebar plugins. I hacked serendipity_plugin_templatedropdown.php template chooser plugin to check if the user is admin so that I can try out different templates:

Code: Select all

function generate_content(&$title) {
        global $serendipity;
        #####################
        #only show the form to admin
        if($serendipity['user'] == 'admin') {
        $title = $this->get_config('title', $this->title);

        $url = serendipity_currentURL(true);

        echo '<form id="theme_chooser" action="' . $url . '" method="post">';
        echo '<select name="user_template" onchange="document.getElementById(\'theme_chooser\').submit();">';
        foreach (serendipity_fetchTemplates() as $template) {
            $templateInfo = serendipity_fetchTemplateInfo($template);
            echo '<option value="' . $template . '" ' . (serendipity_get_config_var('template', 'default') == $template ? 'selected="selected"' : '') . '>' . substr($templateInfo['name'], 0, 25) . '</option
        }
        echo '</select>';

        if ($this->get_config('show_submit', 'false') == 'true') {
            echo '<input type="submit" name="submit" value="' . GO . '" size="4" />';
        }
        echo '</form>';
        }
    }
I wonder if there is a more eloquent solution?

Thanks,
Clint

Re: Displaying plugins only for specific users?

Posted: Fri Sep 17, 2010 12:00 am
by Don Chambers
Go here: http://spartacus.s9y.org/index.php?mode ... s_event_en or use spartacus to fetch the event plugin labeled "Toggle Sidebar state (collapsed/uncollapsed)" which is serendipity_event_sidebarhider. I think it has a configuration option to only allow specified user levels to see whatever plugins you wish.