<h2>诚信宣言</h2>
<label for="introduction">
    <textarea id="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ introduction }}</textarea>
</label>
<p>
    <input type="hidden" id="user_id" value="{{ user_id }}">
    <input type="submit" id="submit" class="button">
</p>
<script>
    (function ($) {
        var oldIntroduction = '{{ introduction }}';
        $(document).ready(function () {
            $('#submit').click(function () {
                var introduction = $('#introduction').val();
                var user_id = $('#user_id').val();
                if (introduction.trim() != '' && oldIntroduction != introduction) {
                    $.ajax({
                        type: 'POST',
                        url: '{{ url }}/wp-admin/admin-ajax.php/',
                        data: 'action=submit_introduction&introduction=' + introduction + '&user_id=' + user_id,
                        success: function (data) {
                            if (data) {
                                alert('提交成功');
                            }
                        }
                    });
                }else{
                    alert('请修改诚信宣言');
                }
            });
        });
    })(jQuery);
</script>