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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog