WordPress.org

Ready to get started?Download WordPress

Forums

WP Password Generator
[resolved] Double Generate Password Button & Future Update (3 posts)

  1. Skate-O
    Member
    Posted 1 year ago #

    As admin I have 2 Generate Password buttons & when signed in as a user, when in profile it also does the same thing. Is there a way to only have 1 Generate Password button?

    Also, I know that all users can use the Generate Password... is there a way to only allow certain users to use this feature (admins only)?

    Thanks,
    Skate-O

    http://wordpress.org/extend/plugins/wp-password-generator/

  2. Skate-O
    Member
    Posted 1 year ago #

    Figured out why I had 2 Password Buttons. It had nothing to do with this plugin! Double Password Buttons = Resolved!

  3. Steve Grunwell
    Member
    Plugin Author

    Posted 1 year ago #

    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!
    -Steve

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.