1

I want to create a user list with the Views module, to change the user status. I use the Views Bulk Operations module, but it has no Change status or Active user action.

How can I enable (or change the status of) users in a view table list with one click?

1

Another approach to roll your own cookies, and create a VBO operation like "change status or active user" (as in your question) yourself. Read on for more details about how to do so ...

Step 1

Use the Rules module to create a Rules Component, which includes whatever Rules Conditions you might need (if any), and with a Rules Action to change status or active user, for the user specified as a parameter for this Rules Component.

Here is such Rules Component you could use for it (in Rules Export format):

{ "rules_change_status_of_a_blocked_user_to_active" : {
    "LABEL" : "Change status of a blocked user to active",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_activate" : { "label" : "User to be activated", "type" : "user" } },
    "IF" : [ { "user_is_blocked" : { "account" : [ "user-to-activate" ] } } ],
    "DO" : [ { "user_unblock" : { "account" : [ "user-to-activate" ] } } ]
  }
}

Some details about it:

  • It uses a user entity as a parameter.
  • The Rules Condition checks that the user to be processed is actually blocked (it doesn't make sense to try to change the status of an active user to active).
  • The Rules Action changes the status of the user to active.

If you have the Rules UI enabled, just import the above Rules Component in your own site. After you completed the import, you can unit test it like so:

  • Use the "Execute" link in front of the Rules Component.
  • On the next screen, where you'll have to enter some value for "User to be activated", use the Switch to the direct input mode button near the bottom.
  • Then enter the uid of some blocked user as the value for User identifier and hit the Execute button below it.
  • The (blocked) user should become active after doing so (which completes your unit testing of this Rules Component).

Step 2

Create an appropriate view of the users for which you want to be able to perform a VBO action like "change status or active user". Then transform that view into a view that uses Views Bulk Operations, and use the technique documented in "How to use Rules to create a custom bulk operation for a VBO view?". In doing so, you'll then be able to use the Rules Component from the previous Step 1.

Tutorial

To get the idea, have a look at the video about Using Rules components with VBO" which uses a Rules Component with (only) 1 parameter. If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: to process like thousands of users at once is quite a challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

  • thanks, Can you help me for create component with rule module for "change status of user to active" step by step? – omiti Nov 4 '17 at 10:49
  • 1
    @omiti check the update I applied to Step 1. A kind of "getting started with Rules". Make sure to "unit test" it as I described, before moving on to Step 2 (it doesn't make sense to try Step 2 if you're not convinced the Rules Component works as designed). Let me know how it goes, ok? – Pierre.Vriens Nov 4 '17 at 11:20
  • I use your help and work for me successfully.your Rules Export was very useful.thanks. That's possible to run this rule only with a link in views fields instead of VBO Select list? So admin click on "activate" link and that user be active. – omiti Nov 7 '17 at 8:16
  • @omiti merci for the confirmation (and accept). May I say "What else did you expect?". Hang on a bit and I'll try to also answer your question in your previous comment here (and notify you via another comment here). – Pierre.Vriens Nov 7 '17 at 8:25
  • In this way and VBO I select action "Change status of a blocked user to active" from dropdown list above of my views table result and click on submit button. If activation is done with a click on the link, it's better. For example add a link for activation to user table row (as a field) and when click on link user gone to active. – omiti Nov 7 '17 at 12:31
2

If you have entity forms and rules, create an entity form with an entity reference to users, add another field for your preferred action, and use rules to perform the action.

1

A possible approach might be to process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

  • Load the VBO list of entities (such as nodes) that you want to be processed.
  • Add a loop to perform a Rules Action, for each entity (such as a node) contained in your Views results. The actual Rules Action you want to perform is "change status or active user action" (as in your question).

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".

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.