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.

changed a wordpress to use custom type posts instead of pages.

I'm Trying to update a plugin to work with this change. currently I'm stuck with just getting the right id from the post here's the relevant code:

add_action ('update_postmeta', 'wp_paypal_meta_change',1,4);

function wp_paypal_meta_change($meta_id,$post_id,$meta_key, $meta_value){
/*
 handles cases of product metadata changes or added.  calls the needed functions:
 get_pp_button or thumb_resize
 and stores their products in hidden paypal variables
*/
    $pid = $post_id;
    //echo($pid);
    if ($meta_key == 'image'){
    $themetaimage = get_post_meta($pid,'image',TRUE);
    $urlp = get_page_link($pid);


    $themetathumb = thumb_resize($themetaimage,148,140,$urlp);//update the image thumb 
    update_post_meta($pid,'_thumb',$themetathumb);//and store it in the variable

    } else if ($meta_key == 'shipping' || $meta_key == 'cost' || $meta_key == 'bookname'){
    $themetacost = get_post_meta($post_id,'cost',true);
    $themetaname = get_post_meta($post_id,'bookname',true);
    $themetashipping = get_post_meta($post_id,'shipping',true);
        if (!$themetashipping) {
                    $themetashipping=($themetacost*0.1);//if no shipping - logic for calculating shipping
                }

This works fine! with pages, but fails miserably with custom type posts

Actually I would be glad to just being able to see to different vars. How can I debug something without seeing it?

share|improve this question
    
    
@goto10 isn't a duplicate, the code is similiar, but the question is specifically about a case where this doesn't work (at least according to the OP) - where using custom post types –  alonisser Apr 4 '13 at 15:50
1  
Can you clarify what you mean by 'fails miserably'? This test code works for me on regular posts and CPTS:add_action ('update_postmeta', 'wp_paypal_meta_change',1,4); function wp_paypal_meta_change($meta_id,$post_id,$meta_key, $meta_value){ exit ( print_r( $post_id ) ); } (By 'works', I mean, the post ID is output using this test.) –  goto10 Apr 4 '13 at 17:56
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.