dpcj40970 2013-04-26 09:22
浏览 175
已采纳

如何在WordPress Post文件中编辑php代码?

I have a wordpress page. In that WordPress page, user will have access to the following Window to Publish their Post in to the webpage.

enter image description here

If the user enters an URL in any of the three filed I have marked in red above, my php code will look in to those URLs and determine if they are spam or not. Therefore, I want to put my php code inside the Publish button, so I can either disallow or allow the post after my php code run and determine if those URLs are spam or not. Can you please tell me the name of the wordpress file I should edit in order to put my php code in. I am new to wordpress and don’t know too much about their file structure.

  • 写回答

1条回答 默认 最新

  • doutian3010 2013-04-26 09:31
    关注

    NEVER edit core files. it is the worst practice that you can choose when working with a ready made cms / publishing system

    you need to filter or hook into some action, there are several ones that are triggered when a post is published ,

    for example the wp_insert_post_data fires when the info is INSERTED to the DB .

    add_filter ( 'wp_insert_post_data' , 'my_filter_function' , 99 );
    

    publish_post is when a post is published, or if it is edited and its status is "published". pre_post_update Runs just before a post or page is updated.

    And so on. see the codex page in the link above to read more about actions, filters and hooks.

    And just so You will not forget : NEVER edit core files.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题