0
votes

I am building a plugin for Wordpress that saved custom data to a custom table every-time a user makes a new post. When I add data to a custom table in wordpress after the publish_post hook is called I am trying to echo the row ID in Chrome's console.

The problem as I see it is that publishing a post on wordpress calls the save_post function and once the post is made it redirects to the post page.

So it is obvious that the echo would not display on the screen but is there a way for these echo's to display in Chrome's console?

1

1 Answers

0
votes

If I well understand what you want, the answer is no.

Chrome console can be accessed using Javascript so you have to send data to the browser in order to display something in the console. And in your case, PHP is saving the post and then redirect without sending anything to the browser.

If you want to get debug info in the Chrome console, you have to generate the log on the page that is displayed to the user. (in your case it's the post display page)

PS: to log info using javascript :

console.log('Your message');