drkug66408 2014-05-09 12:22
浏览 503

在使用WordPress submit_button()提交之前运行PHP函数

I'm creating an options page in WordPress admin interface. How can I run a PHP function before a submit is made?

My HTML:

<div class="wrap">
<h2>Author</h2>
<form method="post" action="options.php">
    <?php settings_fields('author_option_group'); ?>
    <h4>Author Settings</h4>
    <label for="author">Author: </label>
    <input type="text" id="author" name="author" value="<?php echo get_option('author'); ?>" />
    <?php submit_button(); ?>
</form>

The submit_button() above is a wordpress function that generates a submit button that saves the input field to the wp options table in the database. I would like to run a function before the submit is run. The function will do some custom validation etc and maybe throw an error and not run the submit if certain conditions are met.

Regardless of what that function will do, how can I supply a function to be run, which determines if the submit will go through or not?

  • 写回答

2条回答 默认 最新

  • dppx9253 2014-05-09 13:00
    关注

    i think 2 way can help you. 1. change the input type "submit" the file is wp-admin\includes\template.php (unction get_submit_button) 2.use preventDefault

        onsubmit{
        //docheck
        if(checked){
            //nothing do
        }else{
            alert(wrong);
            e.preventDefault
        }
    }
    

    but preventDefault IE not support

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行