PHP code to check for required fiels 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.
Here is how its done:

First create a new rule then,


**Events**
-User has logged in



**Condition**
-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.


**Actions**
-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" } }
]


}
}