2

I am creating Job portal and in that job portal When I create a Job post using admin and save that job as draft instead of posting it to all and for that draft one link is get created and I want to make that job draft link to be accessible to all users including guest.

following is the code for creating draft :

case 'draft':
        $new_node = node_load($job_node_nid,null,true);
        $new_node->status = 0;
        node_save($new_node);
        $_SESSION['bf_job_creation'] = array('step'=>1);
        header('Location: ' . url('my-account'));
        break;

 This above code creates job draft but link to access that draft I just want to make that link to be accessible to all by writing code.

I have tried following code to make link accessible but not succeed :

case 'draft':
    $new_node = node_load($job_node_nid,null,true);
    $new_node->status = 0;
        $new_node->field_job_status = array(array('value'=>'published'));//added this   
    node_save($new_node);
    $_SESSION['bf_job_creation'] = array('step'=>1);
    header('Location: ' . url('my-account'));

break;

how to make the link to job draft public??

1

your problem is $new_node->status = 0; This is setting the node to 'unpublished'. either change the permissions to allow the users to see it or set $new_node->status = 1; To create a link use the l() function eg. l('link text', 'node/'.$node->id);. http://api.drupal.org/api/drupal/includes!common.inc/function/l/7

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.