WordPress.org

Ready to get started?Download WordPress

Forums

Create new/override existing dashboard 'Add New' User page (7 posts)

  1. Matt Jensen
    Member
    Posted 3 years ago #

    Hi there

    For a club website I maintain, I want to enable 'club officers' with appropriate permissions to add new website users, but when new users are added, we need to record more information than just the standard WordPress fields (eg. want to record info such as 'address' and 'phone number'). The important point is that extra fields should be available on the 'Add Users' page in the Dashboard (ie. not the 'register' page). However, after quite a lot of searching, I can't find a way to extend the fields specifically on the 'Dashboard > Users > Add New' page (everything else can be extended or overridden it seems from my searching though).

    I have played with the 'Cimy User Extra fields' plugin, and it does everything I want for extending user fields, except add the fields on the 'Dashboard > Users > Add New' page (note that it does add the fields on the 'registration' page though).

    So I have thought of a few options of how to add the fields I want:

    1) Password protect the 'Register' page with the additional fields as created by Cimy Extra User fields plugin, so that only 'admins' can access the page
    2) Create a completely new 'add new user' page in the admin section (inc. possibly create a new plugin)
    3) override the 'Dashboard > Users > Add New' page, and add the new fields - can anyone tell me if this is possible and how though?
    4) duplicate the 'Dashboard > Users > Add New' page, but modify it so that after creating a user, it redirects to the user 'Profile' page extended by Cimy Extra User fields plugin, so that the extra fields can then be filled in (ie. "step 2").

    What would you recommend is the best way to achieve this, in terms of a 'clean' solution (ie. not hacking the WP core)), as well as not too much development work? (option 1 seems like it'd be good if there's a way to do it but I'm not sure how to restrict it to certain roles?)

    Cheers
    Matt

  2. Matt Jensen
    Member
    Posted 3 years ago #

    Anyone?

  3. kcharity
    Member
    Posted 3 years ago #

    I am trying to do the same thing. I also thought about a restricted 'register' page. Have you made any progress with this?

  4. Matt Jensen
    Member
    Posted 3 years ago #

    Hi there.

    My key criteria for success was 'not modifying WordPress'.

    As such, I've come up with something between a hack and an elegant workaround...!

    I abandoned the 'restricted register' page idea, as I thought it'd be problematic ensuring that the page remained secure.

    What I've done is:
    - Use CIMY User Extra Fields to extend the user profile page (this looks to work for both the user's profile, and the Admin User Editor of a person's profile view).
    - Use 'Theme My Profile' (I couldn't use Theme My Login because of a page layout issue difference between the login and profile) to theme the user's view of their profile
    - created my own custom functions (I put it in a custom plugin actually) that use jQuery/JavaScript to
    1) Hide a couple of fields on the 'User > Add New' page
    2) Added a JavaScript querystring detector on the 'users.php' page, that detects when a new user was just created on the 'User > Add New' page, and redirects to the Admin User Profile Edit page - essentially creating a 2 step process for creating new users and entering all the required data.
    3) hide, rename and rearrange some of default WordPress fields on the Admin profile page that I didn't need
    4) hide, rename and rearrange some default WordPress fields on the user's profile page (same changes as in step #3).

    So the shortfalls of this are that it uses JavaScript/jQuery. However, modifying the core is far more problematic, so I didn't want to do that. This method arguably 'streamlines' WordPress to take advantage of existing features and just rearrange them a bit to suit my needs. Worst case scenario my JS changes break in a WordPress update, but the Admins can still just create the user using the 'User > Add New' page, and then go to the 'Admin > Edit User' page and fill in the rest of their details.

    HTH
    Matt

  5. Matt Jensen
    Member
    Posted 3 years ago #

    FYI, for all of steps 1-4, I used the 'global $pagenow;' variable to check what page was currently loaded, and then load the appropriate JavaScript/jQuery for that page to hide the fields I wanted to hide. I only hid them as opposed to removing them from the form so as not to break any form validation.

  6. webhank
    Member
    Posted 3 years ago #

    any chance you'd share your jquery?

  7. Matt Jensen
    Member
    Posted 3 years ago #

    Sure.

    user-new.js/php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Hope that helps (and turns out in HTML!)
    Cheers
    Matt

Topic Closed

This topic has been closed to new replies.

About this Topic