• My aim is to get a comment with that format: title<!iiTITLE –>content

    I made a filter in function.php to display correctly these comments.

    I have to make one when a user submits the comment. Problem, I also use ajax. So the FORM is: `<form
    id=”awpsubmit_commentform_<?php echo $id;?>”
    class=”comment_form”
    action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php”
    method=”post”
    onsubmit=”<?php title_filter($onsubmit);echo apply_filters(‘awp_commentform_on_submit’,$on_submit); //Leave for AWP features?>”
    >`

    the apply_filter is for ajax, which then redirect to wp_comments_post.php.

    my filters in function.php:

    global $titre;
    add_filter('comment_text','comment_filter');
    add_filter('pre_comment_content','ajoute_titre');
    function comment_filter($content) {
    $i=strpos($content,'<--!TITLE -->');
    if ($i){
    $title='<h3>'.substr($content,0,$i).'</h3>';
    $texte=substr($content,$i+13);
    
    }
    else{
    $title='<h3>'.__('Without Object','stendhal').'</h3>';
    $texte=$content;
    }
    $content=$title.$texte;
    return $content;
    }
    
    function ajoute_titre($content) {
    $content=$titre.'<!--TITLE -->'.$content;
    return $content;
    }
    
    function title_filter($on_submit) {
    $titre = trim($_POST['titre']);
    }

    Og course, it doesn’t work. Some help?

  • The topic ‘modify the content of comment on submit’ is closed to new replies.