So I want to send users of a certain role to a 'manage content' page where they can see all the content they've added. This works great with workflow-ng. However, I run into an issue when one of the two things happens:

1 - They haven't added any content/nodes so it just shows a blank page.
2 - They've just requested a new password - it logs them in and redirects them to their 'manage content' page rather than their profile page (where they'd be able to put in their new password)
3 - They're new users. They click on the link to activate their account and set a password and it forwards them directly to the 'manage content' page rather than being able to set their new password.

I guess it doesn't have to be a full-fledged feature, but if someone could maybe write a php snippet that would check to see if they'd created any content, I could throw that in manually, I guess. I just don't know how to write that... (menoseficaz = Spanish for n00b)

Comments

ifbyphone1’s picture

Fellow noob, I'll take a shot: You could create an ng rule on "user logs in" with no conditions, and use this custom php in the actions:

$authcount = db_query("SELECT COUNT(*) from {node} WHERE uid = %u GROUP BY uid",user -> uid);
if ($authcount == 0) {
drupal_goto('/node/X');
}
else {
drupal_goto('/viewx');
}

Where node X is a page that explains that they have no content available since they are new and/or haven't published anything yet -- put instructions on the page?

And viewx is a view that shows them content in some helpful / sortable way.

Make sense? Try it out -- it should work.

menoseficaz’s picture

tc60045,

Thanks for the reply.

I get the idea and implemented it. I want it to go to the default page they were going to anyway when they login, so I took out the if else and just left the if to check and see if it returned any values. I saved it and tested it by logging in with a user that I know has content written. However, it didn't reroute me to the 'manage content' page... it just did the default. On the bright side, it fixes the other problems, it just doesn't auto-forward to the 'manage content' page like I wanted...

Could it be something in the SQL query?

Also, just to be sure, I'm working w/ Drupal 5.7, FYI.

ifbyphone1’s picture

I used %u, as UID is an unsigned integer in the node table, but now recalling.... Drupal uses a subset of php variable references. See: http://api.drupal.org/api/function/db_query/5 . Sorry!

So change %u to %s. That should do it.

If for some reason you still have trouble, try taking out the $authcount variable and just using the db_query in the if statement directly:
if (db_query(foo) == 0) {...

I've had spotty results with temp variables in the past, but my PHP is rusty.

menoseficaz’s picture

Changed the %u to %s, removed the $authcount variable and replaced it with the query string - still no luck.

Any other thoughts?

Thanks again.

ifbyphone1’s picture

Baffling.
1. This query returns a null value in mysql (30 = new uid, unpublished):

SELECT COUNT(*) from node WHERE uid = 30 GROUP
BY uid

So this should return "you are not an author" when uid 30 logs in:

if (is_null(db_query("SELECT COUNT(*) from {node} WHERE uid = '%s' GROUP
BY uid",$account->uid))) {
drupal_set_message("you are not an author");
}
else {
drupal_set_message("this plain doesn't work right, dog");
}

But it doesn't. I tried this code:

$atest = db_query("SELECT COUNT(*) from {node} WHERE uid = '%s' GROUP
BY uid",$account->uid);
if ($atest == 0) {
drupal_set_message("you are not an author");
}
else {
drupal_set_message($atest);
}

And the message is: 0. So I tried every evaluation method on $atest: is_null(), empty(), == "0" || == 0, ... and none would ever return "you are not an author".

Someone else please help out on this?...