Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:07:44+00:00 2026-05-24T10:07:44+00:00

i have several moderator roles in my drupal site. the users with this roles

  • 0

i have several moderator roles in my drupal site. the users with this roles can create content of specific content-type called News. let’s call the roles the following: role_a, role_b, role_c, …

now i have a View that shows the last 5 News elements.

my question is how to granulate the News elements in View according to the query string?
i mean on page http://mysite.com/a i want to see only the news that was added by the user with the “a” role. http://mysite.com/b is for the “b”-roled user. etc.

how can i use the query string parameters in the Views filter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:07:44+00:00Added an answer on May 24, 2026 at 10:07 am

    I think you mean you want to use an Argument, rather than the query string. In any case, I don’t think Views can handle rolenames by default (it can handle role IDs just fine), so you’ll have to modify your view query in order to achieve what you want.

    First, add User: Roles as an argument in your View. Then, in a custom module, implement hook_views_query_alter() and modify the query by replacing the rolename with its role ID.

    function MYMODULE_views_query_alter(&$view, &$query) {
      if ($view->name == 'my_view') {
        $rolename = '';
        foreach ($query->where as $where_index => $where) {
          // find the role ID clause
          $clause_index = array_search('users_roles.rid = %d', $where['clauses']);
          if ($clause_index !== FALSE) {
            // found it, so get the rolename
            $rolename = $where['args'][$clause_index];
            break;
          }
        }
        // if the rolename argument was found
        if (!empty($rolename)) {
          // get the role ID
          $user_roles = user_roles();
          $rid = array_search($rolename, $user_roles);
          // if the role exists, then replace the argument
          if ($rid !== FALSE) {
            $query->where[$where_index]['args'][$clause_index] = $rid;
          }
        }
      }
    }
    

    So, for example, if your url is http://mysite.com/a, then it will look up the ID of role ‘a’, then find all nodes by an author with that role. It will also take the actual role ID – for example, if the ID of role ‘a’ is 10, then http://mysite.com/10 will also return the same result.

    If you want it only to look up rolenames, you can modify the hook to fail when it doesn’t find the role (just make $rid = 0 and you shouldn’t get any results).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several log files of events (one event per line). The logs can
I'm looking for an elegant pattern to solve this problem: I have several user
I have several process writing to the same log file. How can I synchronize
I have several output listeners that are implementing OutputStream . It can be either
I have several Models: Workspace User Asset WorkspaceUser WorkspaceAsset Workspace has many users and
I have several ASP:TextBox controls on a form (about 20). When the form loads,
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
I have several tables whose only unique data is a uniqueidentifier (a Guid) column.
We have several jobs that run concurrently that have to use the same config
I have several old 3.5in floppy disks that I would like to backup. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.