2

I am using Views to create a view for user management, which looks like in the image below:

enter image description here

How to create an "Active" or "Block" link in my view which performs an operation for the selected user like so:

  1. When I click on "Active" in the Operations column, then the user should be active.

  2. When I click on "Block" in the Operations column, then the user should be blocked.

Note: Views Bulk Operations (VBO) is not working. Refer to the image below. When l select all users in my view results and select "Block current user" as theoperation, then the users are not blocked. I have unstalled the VBO module and re-installed it again. And I also gave permission "user block" to that role. But nothing solved my issue.

enter image description here

  • Is there a reason you don't use (Views Bulk Operations](drupal.org/project/views_bulk_operations) or Administration Views. Those modules are meant specifically for performing actions on views rows. – marcvangend Jul 18 '14 at 15:37
  • I have done this task through views theme... thanks – Sachin Tonte Jul 21 '14 at 6:11
  • OK, if it works for you, why not. But be aware that doing stuff like this in the theme layer may cause trouble later on: Switching themes would cause functionality to disappear; Setting user permissions may not have the expected result; Caching may be less efficient. – marcvangend Jul 21 '14 at 6:55
  • views bulk operation is not working. when l select all users of my views and click on Block operation.. but users not blocked.... i have unstall VBO module again.. install... and also give permission user block to that role.. but not solve my issue – Sachin Tonte Nov 24 '14 at 6:29
  • Hi, can you add right answer (your way) to that issue? – makbuk Aug 14 '17 at 19:02
0

Have a look at the Rules Link module. Some details from its project page:

This module lets you create links which trigger arbitrary functionality with the help of Rules.

Features:

  • Attach the link to any entities.
  • Show the link only for certain bundles.
  • Narrow the entities on which the link will be shown using the visibility conditions.
  • The links are usually displayed using Views.
  • For entities that can be displayed, the links can be shown on node view.
  • Supports an arbitrary number of additional Rules parameters for passing context via Views.
  • 3 types of links: Javascript, Normal and Confirmation form links.
  • Use individual permissions for each link.

Some more details (from its README.txt):

To create a new link go to admin/config/workflow/rules_links and click on "Add rules link". Enter the title of your link and set all the settings. After clicking on the "Save Rules Link" button, the module will generate a new And- and Rules-Set and their forms will be embedded into the rules link editing form.

The And-Sets are called Visibility Conditions and will define when to render the links. The Rules set is the rule, that will be triggered on clicking the rule. Additionally Rules Links also generates access permission for each link, which you'll have to set in admin/people/permissions.

The best way to display the links is currently using views. Rules Links link will create a Views field for each link, using the title of the link as title for the field. So if you have link for nodes with the delete 'Delete node', you'll find the Views field under name 'Content: Delete node'.

Alternatively you can use render the links directly in the entities that can be displayed, using the option 'Show link in entity' in the Rules Links settings.

Note that this will not work for links were the parameters have multiple paramaters.

If you would like to render a link yourself in a theme or in a module, than use the function rules_link_render_link().

Note the "The best way to display the links is currently using views" in the above quoted text, which is pretty close to what you're asking for.

PS: I'm assuming this question is about D7.

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.