Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm adding a box to add / update post screen.

add_action( 'save_post', 'psd_upload_kaydet' );
add_action( 'add_meta_boxes', 'psd_upload' );
function psd_upload()
{
    add_meta_box("psd-upload", "Bir Dosya Upload Edin", "psd_upload_box", "post");
}
function psd_upload_box($post)
{
    echo "content here";
}
function psd_upload_kaydet($post_id)
{
    die($post_id); // for debugging, i'll explain it
}

There is no error while adding box, but normally, when post saved, add_action( 'save_post', 'psd_upload_kaydet' ); will pass post id as an argument to psd_upload_kaydet()

But it's not passing post it to psd_upload_kaydet() as an argument. I'm checking it die($post_id); , but it's returning just blank page.

In shortly, I need post id in psd_upload_kaydet() :)

share|improve this question
add comment

1 Answer 1

die is an alias of exit and from php.net:

void exit ([ string $status ] )

If status is an integer, that value will be used as the exit status and not printed.

Try doing the following instead.

function psd_upload_kaydet($post_id)
{
    echo $post_id;
    die(); // for debugging, i'll explain it
}

edit.

share|improve this answer
    
die()'s parameter will be printed to page : codepad.viper-7.com/tA5Zsn –  Eray Jan 7 '12 at 20:22
1  
I will not flame you for down voting my correct answer. Instead I will just assume you missed the part where I said integers are not printed. codepad.viper-7.com/wgrBDB –  v0idless Jan 8 '12 at 4:31
    
I vote down, because i'm trying die($post_id . " error"); and still getting error. I'll try it again. I'll clear downvote if you edit answer. –  Eray Jan 8 '12 at 13:56
    
There is no need for me to edit my answer because it is correct. die($post_id . "error") will work too. If it doesn't, then you have a problem somewhere else. I'm down voting this question as it is a PHP issue not a WordPress issue, and should therefore be asked on stackoverflow. –  v0idless Jan 8 '12 at 16:00
    
NO you misunderstood. I down voted you and now i can't change my vote to up, if you don't edit your answer. I'm getting : Your vote is now locked in unless this answer is edited error . So, please edit your answer, for example just add a new blank line to your answer :) –  Eray Jan 8 '12 at 21:48
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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