Orange Jello is Mighty Nice

My wife made me some orange Jello with chopped up bananas and oranges in it. I posted before about how much I love pudding cups, and I still do. Let it also be known that I love Jello. A few interesting facts about eating Jello for your bedtime snack...

  • You might knock a cup of water over when you get Jello out of the refrigerator and try to set it on the kitchen table in the dark.
  • You might only find forks in the silverware drawer.
  • It's hard to eat Jello, especially the small pieces at the end, with a fork.
  • It's even harder to finish off a cup of Jello with a fork quietly so as to not wake your loving wife who made you the treat.
  • Jello should be eaten in a bowl, because a cup (once again) just isn't big enough!

Checking if a Drupal User has a Role

UPDATE: Over five years later, this post is still one of the most highly trafficked on my blog. Since then I've learned a lot and shared many other tips and modules. This past year I was honored to be a contributor to The Definitive Guide to Drupal 7, which includes many other great tips like this. I highly recommend it if you want to get the latest and greatest information on developing for Drupal.

I'm a little curious why a simple function to check if a user has a role doesn't exist in Drupal yet. Such curiosity that makes me wonder if I've just managed to miss it as long as I've been working with Drupal, so someone feel free to enlighten me. If anyone is looking for the same, please read on...

A fairly common task for me when adding PHP to CCK fields, Views arguments, content templates, etc. is to check whether the current user has been assigned a certain role. Generally in module development you're dealing with permissions and use user_access(), but when you're just customizing a site you often need such role based logic. (Drupal core has some, like the access settings for blocks.)

Use the following simple snippet to check if a user (in this example, it's the logged in user since I'm getting the global $user) has been assigned a certain role on your site:

global $user;

// Check to see if $user has the administrator role.
if (in_array('administrator', array_values($user->roles))) {
// Do something.

Replace 'administrator' with whatever role it is you're trying to check against. Alternatively, if you keep a helper module for use on your projects, go ahead and drop this function in it:

 * Check to see if a user has been assigned a certain role.
 * @param $role
 *   The name of the role you're trying to find.
 * @param $user
 *   The user object for the user you're checking; defaults to the current user.
 * @return
 *   TRUE if the user object has the role, FALSE if it does not.
function user_has_role($role, $user = NULL) {
  if (
$user == NULL) {

  if (
is_array($user->roles) && in_array($role, array_values($user->roles))) {


Please let me know if I put a typo up here or you know of an existing or easier way to do this!

Alan Johnston's Captivity

You don't have to agree with all his politics to be moved by Alan Johnston's recounting of his captivity and release in Gaza. He faced unbelievable challenges apparently with much dignity, and God protected his life in the middle of a very dangerous situation through groups we would even consider to be enemies.

Check it out here:

The Rich Young Ruler

One of my favorite stories in the gospels is that of the rich young ruler found in all three of the synoptic gospels (Matthew, Mark, and Luke). I've taught this passage several times to recovering addicts with varied results, and the general conclusion is that we're just as helpless to save ourselves as that man was. The rich young ruler was seeking eternal life from the one man alive who could have led him to take hold of it, and even though he lay at the Savior's feet, he was still miles away from salvation.

I feel like I should devote pages and pages to telling and retelling this man's story. I'll only touch on him now, though, and trust that some other time I'll "pick up the pen" and blog about him again. For those who are curious, like me, you might wonder why in the world we call this man a rich young ruler at all. I particularly like teaching the story from Mark 10 (I'll get to why), and here we only learn that he was rich (Mk 10:22). However, the parallel accounts give us a fuller picture. In Matthew the man is described as young and rich (Mt 19:22), and in Luke 18 we learn that he is indeed a ruler (Lk 18:18).

So, the man of whom the account is told is known to be rich, young, and a ruler. I like teaching the story from Mark, because I find his particular way of story telling to be revealing of several other aspects of the man's character... and these are indeed aspects of much greater worth. For most of those reading this page, you will agree that we are neither rich, all young, or rulers of any sort. And I think it is popular to look down on this man for his pride, arrogance, and love of money. When I read the story, though, I feel more ashamed than I do smug... and here's why.

First, this man possesses a particular audacity and shamelessness. The opening verse of Mark's account sets the stage for this... Jesus is leaving town, indeed marching off to Jerusalem where he intends to submit to injustice and die on the cross. As Jesus is leaving town, all of a sudden someone comes running up behind him. Generally these people have been beggars, poor, needy. They've been blind, had withered hands, had sick children. But this man is none of these! He is fit, in his prime. He is maybe envied and certainly respected for his wealth and position. And here he is running down the road after Jesus! He's realized he is about to miss the chance of a lifetime, the opportunity to ask Jesus the question of all questions, and so he drops whatever it was he was doing or whoever it was he was talking to and tears off down the road to catch up to Jesus.

What he does next is my second point... this man who would be just fine living proud proves to be incredibly humble. He has just made a fool of himself running off after Jesus, and as soon as he catches up he kneels down on the ground before him. This ruler kneels before Jesus, taking the place of the servants who may indeed have been bowing before him. Not only is his humility expressed in his posture, but it is expressed in his purpose. He has come all this way to ask Jesus a question. He might have asked it from any other man, any other Rabbi or scholar. But he ran down the street after Jesus to ask him how he might inherit eternal life. Honestly, this isn't the sort of question you just ask anyone. You want to know the answer you'll receive is authoritative. You want to know the answer you get is right. If you're concerned for your soul, you want to find real answers. He expected to find all these in Jesus' response. Thus he prostrated himself before the Lord and so proved to be more humble than I often am.

Finally, for this post anyways, the rich young ruler was bold in his address. It would have been safe to call Jesus Jesus. It would have been safe to call him Rabbi. It even proved safe for others to call him the Son of David and Lord. But this man calls him Good Teacher and almost has to put his foot in his mouth. I don't believe Jesus is necessarily rebuking him, but I do imagine he might be probing the man's heart to see if he does indeed believe Jesus is God. "No one is good but One--God." So what is it, young ruler. Do you believe I am God, or are you trying to gain favor from a mere man? While we could say that he may have just been confused, for indeed in verse 20 he drops the "Good" and just calls Jesus teacher, I think it's incredible that he would call Jesus Good Teacher at all! Who among us falls before Jesus and first calls him the good teacher whose advice we most need and eagerly seek? How often do I turn to Jesus' counsel when my path is unclear or my plans are falling apart? And yet this man calls Jesus Good Teacher and comes to him looking for the ultimately wise answer to the ultimate question, "What must I do to inherit eternal life?"

And what's amazing is I honestly believe he expected to find an answer. He was not a Pharisee trying to prove himself righteous. He was not a Sadducee trying to trip Jesus up in his speech. He wasn't a Roman soldier mocking him as a wise man. He was an honest seeker showing great promise in his approach looking for the answer to life's greatest question. He believed Jesus possessed the eternal life he needed, and he was willing to look the fool, humble himself, and confidently ask the Lord how he might indeed lay hold of it. May we approach Jesus in our own lives like this man. Amen.