Support » Plugins and Hacks » WP Password Generator » [Resolved] Double Generate Password Button & Future Update

[Resolved] Double Generate Password Button & Future Update

Viewing 2 replies - 1 through 2 (of 2 total)
  • Figured out why I had 2 Password Buttons. It had nothing to do with this plugin! Double Password Buttons = Resolved!

    Plugin Author Steve Grunwell


    Hi Skate-O,

    I’m glad the double button issue resolved itself for you. As for restricting the generate password button to administrators there isn’t anything like that built into the plugin but if you really needed to you could drop something like this into your theme’s functions.php (disclaimer: this code is untested):

     * Only show the WP Password Generator button for administrators
     * @uses current_user_can()
     * @uses is_admin()
     * @uses wp_dequeue_script()
    function mytheme_hide_generate_password_button_for_non_admins() {
      // If the current user can't update plugins he/she is likely not an admin
      if ( ! current_user_can( 'update_plugins' ) ) {
        wp_dequeue_script( 'wp-password-generator' );
    add_action( 'admin_init', 'mytheme_hide_generate_password_button_for_non_admins' );

    Something like that will dequeue the WP Password Generator javascript file (which does ~90% of the work of the plugin) for any user who doesn’t have the update_plugins capability (this could easily be replaced with any other admin-only or custom capability). Running the function at admin_init ensures we’re not weighing down the public-facing site as this hook is only (supposed to be) fired in the admin area.

    Hope that helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Double Generate Password Button & Future Update’ is closed to new replies.
Skip to toolbar