Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Susan Resko on
How can I modify the PHP code for "Show block only to a particular user", so that it will show the block only to 8 particular users? How will this line look if I do that: ($user->uid == 1) what is the convention to list the 8 different uid numbers. I'm guessing it might be something like: ($user->uid == 1; 5; 17; 18; 20; 22; 24; 25) Will something like this work? How do I write that?
Comments
The first thing that comes
The first thing that comes to mind: create a role for these 8 users, then limit the visibility of the block to that role. Might be easier than php coding inside the block.
----------------------------------------------------------------------
http://www.bwv810.com/
I am a writer and researcher. In my spare time I build websites with Drupal.
Je peux communiquer en français. / Я могу общаться на русском языке.
Can you give me a hint?
A brief outline of the steps involved in doing that would be helpful, such as - go here, do this, then go there, do that.
Of course.--Go to user
Of course.
--Go to user management, roles.
--Create a new role
--Edit the permissions so these users can at a minimum view content.
--Save permissions.
--Go to User management, users.
--Edit each of these 8 users accounts by assigning each of them the role you have just created.
--Go to blocks, find the block you are working with, click configure.
--Look beneath the block body for "role specific visibility settings" and "show block for specific roles" and click the role you created in bullet 2 above.
Now only these 8 people will see that block when they log in.
----------------------------------------------------------------------
http://www.bwv810.com/
I am a writer and researcher. In my spare time I build websites with Drupal.
Je peux communiquer en français. / Я могу общаться на русском языке.