4

I'm heavelly modified my Wordpress, it's amazing what you can do with wordpress hooks, actions.. But i'm not able to find how can i add mass action for users. Let's say i select 5 users and i want to asign them some user_meta value.

3

Unfortunately this isn't possible. Custom actions cannot be added to the bulk actions dropdown (see trac tickets: http://core.trac.wordpress.org/ticket/12732 and http://core.trac.wordpress.org/ticket/16031).

For posts you can use the restrict_manage_posts hook to create another drop-down / add buttons to trigger your custom action. But there is no restrict_manage_* hook available for the user table.

So the only (and not particularly pretty) workaround is to use javascript to insert extra options into the drop-down menu.

However, there is no (supported) way of handling the action - so this would also have to be handled yourself by hooking into the load-* or admin_action_* hook. (See the core files here).

You would then need to check the posted data (the user IDs, the action identifier, nonce, etc) inside that hook and then you would need to check the nonce and the current user's capability to perform that action.

See related question: Custom bulk_action

  • Another alternative, albeit also time consuming to implement, would be a custom built (secondary) user table in a custom admin menu, @Tommix. | +1 for sharing the tickets – Johannes Pille Jun 4 '12 at 13:10
1

It's possible by using jQuery to add the item to the drop down or adding another field and then use Ajax to intercept the click and perform your bulk action that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.