2

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.

0

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

} }

| improve this answer | |
  • Sorry looks like i misunderstood your requirements, please ignore post above. – saadlulu Sep 22 '12 at 10:13
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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