WordPress.org

Forums

WPMU Ldap Authentication
Patch for Admin Toolbar to use LDAP add user page (6 posts)

  1. yalet
    Member
    Posted 2 years ago #

    The default behavior in WordPress 3.4.1 with WPMU Ldap Version 4 leaves the admin toolbar (at the top of the page by default) with the Local Add User page linked in the New->User option. I wrote a patch for WPMU Ldap that hooks in and replaces the link to the Local Add User page with a link to the Ldap Add User page.

    diff -Naur --strip-trailing-cr a/wpmuldap/ldap_auth.php b/wpmuldap/ldap_auth.php
    --- a/wpmuldap/ldap_auth.php	2012-08-22 16:04:57.000000000 -0400
    +++ b/wpmuldap/ldap_auth.php	2012-08-28 11:55:33.380330993 -0400
    @@ -63,4 +63,6 @@
     	// disable default add user box
     	add_filter('show_adduser_fields', 'wpmuLdapDisableShowUser');
    
    +	//override admin toolbar option for creating user accounts
    +	add_action('wp_before_admin_bar_render', 'wpmuLdap_custom_admin_bar_render');
     }
    diff -Naur --strip-trailing-cr a/wpmuldap/lib/wpmu_ldap.functions.php b/wpmuldap/lib/wpmu_ldap.functions.php
    --- a/wpmuldap/lib/wpmu_ldap.functions.php	2012-08-22 16:04:57.000000000 -0400
    +++ b/wpmuldap/lib/wpmu_ldap.functions.php	2012-08-28 11:57:18.212333798 -0400
    @@ -416,3 +416,21 @@
     function wpmuLdapSSODisableReauth($login_url){
     	return str_replace('&reauth=1','',$login_url);
     }
    +
    +
    +/*
    ++ * Override the add user functionality in the admin toolbar to use the
    ++ * LDAP Add User page instead of the default WordPress add user page
    ++ */
    +function wpmuLdap_custom_admin_bar_render() {
    +	 global $wp_admin_bar;
    +	 $wp_admin_bar->remove_menu('new-user');
    +	 $wp_admin_bar->add_menu( array(
    +	 	'id' => 'new-user',
    +		'title' => 'User',
    +		'href' => admin_url() . "tools.php?page=wpmu_ldap_adduser.functions.php",
    +		'parent' => 'new-content',
    +		'meta' => array(
    +			'title' => _x( 'User', 'add new from admin bar' ), 'new-user' ),
    +		));
    +}

    http://wordpress.org/extend/plugins/wpmuldap/

  2. Aaron Axelsen
    Member
    Plugin Author

    Posted 2 years ago #

    Nice catch - will get this added in.

  3. Michael
    Member
    Posted 2 years ago #

    I applied yalet's patch manually, myself, and it worked great. I did change "tools.php?page=wpmu_ldap_adduser.functions.php" to "users.php?page=wpmu_ldap_adduser.functions.php" just for consistency, although both work.

    Is it possible to make a similar change to the "Add New" button on the All Users page?

    I am looking at users.php in WordPress core (lines 404 and 406 in WP 3.4.2), and the code that renders that button does not seem as easy to alter with a function.

  4. Michael
    Member
    Posted 2 years ago #

    I gave this one some more thought, and I decided that adding an .htaccess redirect would be much better than hacking WordPress core.

    # Redirect to WPMU LDAP Authentication Add User page
    RedirectPermanent /wp-admin/network/user-new.php /wp-admin/network/users.php?page=wpmu_ldap_adduser.functions.php
    RedirectPermanent /wp-admin/user-new.php /wp-admin/users.php?page=wpmu_ldap_adduser.functions.php
  5. Aaron Axelsen
    Member
    Plugin Author

    Posted 2 years ago #

    There is another way to get ride of this be changing the caps. I need to add this as an option into the plugin yet.

  6. Samuel Parsons
    Member
    Posted 2 years ago #

    Is it possible to make a similar change to the "Add New" button on the All Users page?

    I am looking at users.php in WordPress core (lines 404 and 406 in WP 3.4.2), and the code that renders that button does not seem as easy to alter with a function.

    It seems that we need to change more than the link. The code in user-new.php allows a user to add another user, so it would need to be disabled, not just the link removed in order to really have all the bases covered. I'm not sure where to begin with this, or else I'd start a patch.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WPMU Ldap Authentication
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.