I'm using the Rules module in my Drupal site to do the following:

  • when an existing user logs in
  • check if there are required fields of the user account that have no value yet
  • redirect to the user page and show a message

This is necessary, because we have added required fields to the user account. My problem is with the second step. I can add a check for every required field, but would like to use a more generic approach.

What I'm looking for is PHP code to check if the current logged in user has required fields that are empty.

I am a developer but in .NET and have no PHP knowledge, though I'm willing to learn and I'm confident I'll pick up quickly.


2 Answers 2


Here is how its done:

First create a new rule then,

-User has logged in
-Data Value is empty

you have to enter the value u want to check, something like site:current-user:field-skills make sure to change field-skills to the field name you want to check.

-Show a message on the site 
"enter the message you want"
-page redirect
"enter uri to redirect to"

here is an export of the rule:

{ "rules_check_required_fields" : {
"LABEL" : "Check required fields",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_login" ],
"IF" : [
  { "data_is_empty" : { "data" : [ "site:current-user:field-skills" ] } }
"DO" : [
  { "drupal_message" : { "message" : "Field skills is empty", "type" : "warning" } },
  { "redirect" : { "url" : "\u003Cfront\u003E" } }

} }

  • Sorry looks like i misunderstood your requirements, please ignore post above.
    – saadlulu
    Sep 22, 2012 at 10:13

Turns out there is a module that handles this perfectly: Complete Profile. That's the one I use, but there's also Profile Fields Force Filling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.