I wanted the ability to accept multiple User IDs as a contextual filter similar to Node IDs. I have modified the views_plugin_argument_validate_user.inc file to allow this capability. I will attach the patch to the following post.

Files: 
CommentFileSizeAuthor
#10 Contextual_Filter_UserID_Multiple-1798270-10.patch7.61 KBweekbeforenext
PASSED: [[SimpleTest]]: [MySQL] 1,652 pass(es).
[ View ]
#9 Contextual_Filter_UserID_Multiple-1798270-9.patch7.48 KBweekbeforenext
PASSED: [[SimpleTest]]: [MySQL] 1,652 pass(es).
[ View ]
#5 Contextual_Filter_UserID_Multiple-1798270-2.patch6.26 KBweekbeforenext
PASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).
[ View ]
#1 Contextual_Filter_UserID_Multiple-1798270-1.patch5.74 KBweekbeforenext
PASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new5.74 KB
PASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).
[ View ]

Attached is a patch that allows multiple User IDs as Contextual Filter.

Status:Needs review» Needs work

I see some changes that need to be made to that patch. I'm going to work on it more.

There's nothing to indicate in the interface that it won't work for user ids, but it doesn't work for me. Eagerly awaiting a patch for this, thanks.

Marked http://drupal.org/node/1534720 as a duplicate.

Status:Needs work» Needs review
StatusFileSize
new6.26 KB
PASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).
[ View ]

I reworked the views_plugin_argument_validate_user.inc file and created a new patch. The validation seems to work, but if you enter multiple users, I can't figure out where the view is modified to use the IN operator instead of the = operator. Does anyone know where that needs to be changed? Otherwise, you can use hook_query_alter to modify the query for specific instances. I really want to figure out how to set the correct operator though.

Was this solved in the end (changing = to IN)?

For people having problem with operator (= instead IN).

For me worked to delete line $this->argument->argument = implode(', ', $account_uids); (after patch this is line 173 in views_plugin_argument_validate_user.inc)

Also make sure "Allow multiple values" checkbox is checked. Hope I help someone.

I had to solve this by using hook_views_query_alter(). I'm not sure how removing that line fixed the problem, but I will look into it. Maybe the value should just be $account_uids instead of an imploded version. I will take a look at this when I have time. Thanks for your input.

StatusFileSize
new7.48 KB
PASSED: [[SimpleTest]]: [MySQL] 1,652 pass(es).
[ View ]

I finally had some time to investigate this further. adrian.andrzejewski, you were on to something. However, the problem was the space after the column in the implode statement: ', '. When the space was removed, it worked fine.

While investigating the problem with multiple uids/usernames, I noticed that if there was a space in the argument for nids, it caused a problem as well. I added some code to strip out spaces in the argument for both.

Please consider the attached patch.

Thanks,
April

StatusFileSize
new7.61 KB
PASSED: [[SimpleTest]]: [MySQL] 1,652 pass(es).
[ View ]

Attached is a patch that will not trigger trailing whitespace errors when applied.

Thanks,
April