Problema la adaugarea unui comentariu folosind un buton
-
Ceau,
Am aceasta functie in functions.php:
function voteaza_lucrare( $comm_post_id, $comm_author, $comm_email, $comm_content, $userID ) { $time = current_time('mysql'); $data = array( 'comment_post_ID' => $comm_post_id, 'comment_author' => $comm_author, 'comment_author_email' => $comm_email, 'comment_author_url' => 'http://startut.ro', 'comment_content' => $comm_content, 'comment_type' => '', 'comment_parent' => 0, 'user_id' => $userID, 'comment_author_IP' => '127.0.0.1', 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', 'comment_date' => $time, 'comment_approved' => 1, ); wp_insert_comment($data); }
Aceasta functie functioneaza perfect, problema este ca…
Incerc sa folosesc aceasta functie in comment-template.php ca si link pentru un buton:
<div style="float: right;"><a href="<?php voteaza_lucrare(get_the_ID(), $current_user->user_login, $current_user->user_email, 'Vot ' . get_comment_author , $current_user->ID ); ?>" class="button facebook"><font color="#ffffff">Votează această lucrare</font></a></div>
Problema este atunci cand intru pe un post, imi adauga comentarii automat, as dori ca sa-mi adauge comentariu doar atunci cand apas pe acel buton.
Am incercat ca sa folosesc evenimentul onclick, dar nu am reusit, sau poate nu l-am folosit eu cum trebuie.
Multumesc.
- Subiectul „Problema la adaugarea unui comentariu folosind un buton” este închis pentru răspunsuri noi.