Not a easy task to explain my problem, but I'll give it a try...
I'm building feature-rich user profiles on my site using the node profile family-modules. Anyway, in order to make things clean I use my own "edit userprofile" page where users can change there profile information.

My current problem is that every time a user updates his/her profile, the node gets unpublished... because of the code I'm using (found on a tutorial):

<?php
global $user;
if (in_array('administrator',$user->roles)) {
  // This line prints everything, including fields we haven't specified
  print drupal_render($form);
} else {
  // This prints just the fields that we've specified to keep it simple for regular users
  print drupal_render($form['form_token']);
  print drupal_render($form['form_id']);
  print drupal_render($form['preview']);
  print drupal_render($form['submit']);
  print drupal_render($form['delete']);
}
?>

The node gets unpublished when the publishing option isn't printed I guess, since when I remove this part and replace it with just "print drupal_render($form);", it seems to work, but it prints a lot of information I don't want. Is there a way to just print the Publishing option, or is there another way I can fix this?

Thanks

Comments

nancydru’s picture

Hook_nodeapi has the capability to set/unset the workflow options. For "published," the name is actually "status." So your code (op='submit' or 'insert') would be node->status = 1;. Fairly simple.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

NeoID’s picture

Thanks for your reply, but I'm new to Drupal and not really familiar with the use of the API yet, where do I have to put the code "node->status = 1;"?

artycul’s picture

hey NeoID!

Have you already found out how to solve this?
It may seem, I'm lazy and just want an out-of-the-box-solution, but thats not true. I've been reading a lot about hook_nodeapi, but just can't get it to work... any further help on how to call this would be very appreciated. Thanks a lot...

...sebi

nancydru’s picture

Here's an example from a module I wrote. I don't set it, but you should be able to get the idea.

function pinkslip_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($node->type != 'pinkslip') { return; }   /* don't do any others */

  switch ($op) {
    case 'submit':
       if (!$node->status) {
        $msg = t('Your Pink Slip article is queued for approval. ');
        if (!user_access('Administer Pink Slip')) { /* see if they can approve it themselves */
          $msg .= t('The admininstrator will decide whether and when it will be published.');
         } /* end if */
        drupal_set_message($msg);
       } /* end status */
...

This goes into a module.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

frenzo’s picture

So can you be specific in where to put to codes in?