How to load a variable through different nodeapi's $op? I have a registration form on which I ask if user want to participate to a certain program ; if he clicks "yes", then i have a conditional field which requires to upload a picture. There are some problems for validating a picture with drupal, so I decided to create my own validation system. 

If the user clicks on "yes" but doesn't upload a picture, then there must be an error message. If the user clicks on "no", the user can't upload a picture (thanks to conditional field).

For that, I've written this under a hook_nodeapi() function :

        if ($op=='validate'){
        if($node-&gt;type == 'profile'){
            // check if the user accepted or not
            if ($node-&gt;field_prof_firstflash[0]['value']=="Yes"){
                //check if there's an image loaded
                    if ($node-&gt;field_prof_img[0]['filesize'] == 0)
                        form_set_error('field_prof_img', t('Please upload a profile picture.'));
                }
            }
        }
    }


The problem comes when a user wants to edit his settings, later. If the user said "Yes" before but eventually wants to turn it off, my preceding code won't work anymore since $node-&gt;field_prof_firstflash[0]['value'] is still set to "Yes". Then, I thought about loading a variable when $op=='prepare' like :

        if ($op =='prepare'){
        $firstflash = $node-&gt;field_prof_firstflash[0]['value'];
        $img=$node-&gt;field_prof_img[0]['filesize'];

    }
    if ($op=='validate'){
        if($node-&gt;type == 'profile'){
            // check if the user accepted or not
            if ($firstflash=="Yes"){
                //check if there's an image loaded
                    if ($img == 0)
                        form_set_error('field_prof_img', t('Please upload a profile picture.'));
                }
            }
        }
    }


But of course (this would have been too simple :-) ), $firstflash is not loaded when $op=='validate', even with that piece of code...

Does anyone has any idea on how to do that?
At first sight, it looks like you would be better off implementing hook_form_alter, adding a custom validation handler. A form validation handler will give you access to the submitted values in $form_state as well as the previously stored values.