How to Debug the ‘save_post’ Action?

Your code works just fine on my end. So, I’d say your problem is elsewhere.

Troubleshooting guide.

You can use standard debugging or FirePHP. I also use the following for cases where FirePHP doesn’t display information, i.e., save_post.

function my_log( $msg, $title="" )
{
    $error_dir="/Applications/MAMP/logs/php_error.log";
    $date = date( 'd.m.Y h:i:s' );
    $msg = print_r( $msg, true );
    $log = $title . "  |  " . $msg . "\n";
    error_log( $log, 3, $error_dir );
}

And inside your action callback: my_log( $_POST, 'Contents of $_POST' );.


As far as I know, there’s no such thing as “validate PHP”.
There are editors that’ll show errors while you write: http://www.jetbrains.com/phpstorm/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)