<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote? - How-to and Troubleshooting				            </title>
            <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/</link>
            <description>wpDiscuz WordPress Comment Plugin Community. Support and Resources.</description>
            <language>en-US</language>
            <lastBuildDate>Mon, 05 Oct 2026 11:30:56 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13094</link>
                        <pubDate>Wed, 26 Jan 2022 11:38:09 +0000</pubDate>
                        <description><![CDATA[@stevara,
this is wordpress defult table, 
$wpdb-&gt;update($wpdb-&gt;commentmeta, ...) -- this is working
but this one is not a defult 
$wpdb-&gt;insert($wpdb-&gt;wc_users_voted, ...) -...]]></description>
                        <content:encoded><![CDATA[<p>@stevara,</p>
<p>this is wordpress defult table, </p>
<p><span>$wpdb-&gt;update($wpdb-&gt;commentmeta, ...) -- this is working</span></p>
<p>but this one is not a defult </p>
<p><span>$wpdb-&gt;insert($wpdb-&gt;wc_users_voted, ...) --- this is not</span></p>
<p><span>This $wpdb-&gt;insert($wpdb-&gt;wc_users_voted, ...) should be a $wpdb-&gt;insert('<span style="color: #ff0000">wp_</span>wc_users_voted', ...)</span></p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>Asti</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13094</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13092</link>
                        <pubDate>Wed, 26 Jan 2022 10:49:58 +0000</pubDate>
                        <description><![CDATA[@asti
But when I used commentmeta, I didn&#039;t put that prefix and it worked.
$wpdb-&gt;update($wpdb-&gt;commentmeta, ...) -- this is working
$wpdb-&gt;insert($wpdb-&gt;wc_users_voted, ...) ...]]></description>
                        <content:encoded><![CDATA[<p>@asti</p>
<p>But when I used commentmeta, I didn't put that prefix and it worked.</p>
<p>$wpdb-&gt;update($wpdb-&gt;commentmeta, ...) -- this is working</p>
<p>$wpdb-&gt;insert($wpdb-&gt;wc_users_voted, ...) --- this is not</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>stevara</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13092</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13075</link>
                        <pubDate>Wed, 26 Jan 2022 08:54:32 +0000</pubDate>
                        <description><![CDATA[@stevara,
There is no such a $wpdb-&gt;wc_users_voted table in the wpdb. You should replace this {$wpdb-&gt;wc_users_voted} with this wp_wc_users_voted string. 
In your case, the wp_ can b...]]></description>
                        <content:encoded><![CDATA[<p>@stevara,</p>
<p>There is no such a $wpdb-&gt;wc_users_voted table in the wpdb. You should replace this {$wpdb-&gt;wc_users_voted} with this <span style="color: #ff0000">wp_</span>wc_users_voted string. </p>
<p>In your case, the wp_ can be different. </p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>Asti</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13075</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13058</link>
                        <pubDate>Mon, 24 Jan 2022 16:21:40 +0000</pubDate>
                        <description><![CDATA[last_error is: Unexpected &#039;&lt;&#039;
I didn&#039;t set show_errors() before...]]></description>
                        <content:encoded><![CDATA[<p><em>last_error</em> is: Unexpected '&lt;'</p>
<p>I didn't set show_errors() before...</p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>stevara</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13058</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13057</link>
                        <pubDate>Mon, 24 Jan 2022 16:00:42 +0000</pubDate>
                        <description><![CDATA[@asti Everything works now. The number of likes or dislikes change as they should. But just to clear the thing that is bothering me. Update on commentmeta works and practically just that upd...]]></description>
                        <content:encoded><![CDATA[<p>@asti Everything works now. The number of likes or dislikes change as they should. But just to clear the thing that is bothering me. Update on <strong>commentmeta</strong> works and practically just that update and the code below (that you sent with $postId instead of $commentId - think that was a mistake)</p>
<pre contenteditable="false">if (wpDiscuz()-&gt;options-&gt;thread_display ) {
                do_action("wpdiscuz_reset_comments_cache", $postId);
            } else {
                do_action("wpdiscuz_reset_comments_extra_cache", $postId);
            }
            do_action("wpdiscuz_clean_post_cache", $postId, "comment_voted");</pre>
<p>do the job.</p>
<p>The insert statement on <strong>wc_users_voted</strong> table doesn't add new row (and $wpdb-&gt;last_error is just empty string). Maybe I'm making a mistake somewhere:</p>
<pre contenteditable="false">$vote = 1;
$date = current_time("timestamp");
$userIp = md5(getUserIP());

// $commentId and $postId are valid numbers and getUserIp() return my ip address

$sql = $wpdb-&gt;prepare("INSERT INTO `{$wpdb-&gt;wc_users_voted}` (`user_id`, `comment_id`, `vote_type`,`is_guest`,`post_id`,`date`)VALUES(%s,%d,%d,%d,%d,%d);", $userIp, $commentId, $vote, 1, $postId, $date);
$wpdb-&gt;query($sql);</pre>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>stevara</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13057</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13046</link>
                        <pubDate>Mon, 24 Jan 2022 11:17:21 +0000</pubDate>
                        <description><![CDATA[@stevara,
Please use this one: 
if (wpDiscuz()-&gt;options-&gt;thread_display ) {
                do_action(&quot;wpdiscuz_reset_comments_cache&quot;, $commentId);
          ...]]></description>
                        <content:encoded><![CDATA[<p>@stevara,</p>
<p>Please use this one: </p>
<pre contenteditable="false">if (wpDiscuz()-&gt;options-&gt;thread_display ) {
                do_action("wpdiscuz_reset_comments_cache", $commentId);
            } else {
                do_action("wpdiscuz_reset_comments_extra_cache", $commentId);
            }
            do_action("wpdiscuz_clean_post_cache", $commentId, "comment_voted");</pre>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>Asti</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13046</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13045</link>
                        <pubDate>Mon, 24 Jan 2022 10:53:03 +0000</pubDate>
                        <description><![CDATA[@asti I see now that I also have to reset the cache. But how can I access options-&gt;thread_display in my function.php file?
I see that options is a WpdiscuzOption object with dbManager as...]]></description>
                        <content:encoded><![CDATA[<p>@asti I see now that I also have to reset the cache. But how can I access options-&gt;thread_display in my function.php file?</p>
<p>I see that options is a WpdiscuzOption object with dbManager as parameter (WPDiscuzCore.php)</p>
<pre contenteditable="false">$this-&gt;dbManager = new WpdiscuzDBManager();
$this-&gt;options = new WpdiscuzOptions($this-&gt;dbManager);</pre>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>stevara</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13045</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13043</link>
                        <pubDate>Mon, 24 Jan 2022 10:40:03 +0000</pubDate>
                        <description><![CDATA[@stevara,

Can I get the meta_value field from comment_meta in my endpoint, change it and then update the comment_meta database?

Yes, you&#039;re right. 

Also with the wc_users_voted tabl...]]></description>
                        <content:encoded><![CDATA[<p>@stevara,</p>
<blockquote>
<p><span>Can I get the </span><strong>meta_value</strong><span> field from </span><strong>comment_meta</strong><span> in my endpoint, change it and then update the </span><strong>comment_meta</strong><span> database?</span></p>
</blockquote>
<p>Yes, you're right. </p>
<blockquote>
<p><span>Also with the </span><strong>wc_users_voted</strong><span> table but I see that I will need to add new row there (although there is an </span><strong>UPDATE</strong><span> statement in </span><em>updateVoteType</em><span>). The </span><strong>user_id</strong><span> will then need to be an ip address of the user if I'm right?</span></p>
</blockquote>
<p>This is also correct. You can use the user IP as a value of the user ID. Just a bit of correction. You should use the INSERT instead of the UPDATE statement in updateVoteType. </p>
<p>Also, please use the code below for deleting the caches:</p>
<pre contenteditable="false">if ($this-&gt;options-&gt;thread_display) {
                do_action("wpdiscuz_reset_comments_cache", $commentId);
            } else {
                do_action("wpdiscuz_reset_comments_extra_cache", $commentId);
            }
            do_action("wpdiscuz_clean_post_cache", $commentId, "comment_voted");</pre>
<p> </p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>Asti</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13043</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13040</link>
                        <pubDate>Mon, 24 Jan 2022 10:22:31 +0000</pubDate>
                        <description><![CDATA[I see that update_comment_meta function is being called where I guess comment_meta table is being updated. And also updateVoteType function in WPDiscuzDBManager.php where  wc_users_voted tab...]]></description>
                        <content:encoded><![CDATA[<p>I see that <em>update_comment_meta</em> function is being called where I guess <strong>comment_meta</strong> table is being updated. And also <em>updateVoteType</em> function in <em>WPDiscuzDBManager.php where </em> <strong>wc_users_voted</strong> table is updated.</p>
<p>Can I get the <strong>meta_value</strong> field from <strong>comment_meta</strong> in my endpoint, change it and then update the <strong>comment_meta</strong> database?</p>
<p>Also with the <strong>wc_users_voted</strong> table but I see that I will need to add new row there (although there is an <strong>UPDATE</strong> statement in <em>updateVoteType</em>). The <strong>user_id</strong> will then need to be an ip address of the user if I'm right? (I allow anonymous commenting and voting). And if <strong>id</strong> field in that table is somehow set to be auto filled..</p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>stevara</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13040</guid>
                    </item>
				                    <item>
                        <title>RE: Can I use wpdiscuz in my theme function.php file in an endpoint to add new vote?</title>
                        <link>https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13037</link>
                        <pubDate>Mon, 24 Jan 2022 09:26:30 +0000</pubDate>
                        <description><![CDATA[Hi @stevara,
We&#039;re really sorry, but there is no way for adding like/dislike via REST API.
You can view the &quot;voteOnComment&quot; method in the WpdiscuzHelperAjax class, it&#039;ll help you better un...]]></description>
                        <content:encoded><![CDATA[<p>Hi @stevara,</p>
<p>We're really sorry, but there is no way for adding like/dislike via REST API.</p>
<p>You can view the "<span style="color: #008000"><em><strong>voteOnComment</strong></em></span>" method in the <strong><span style="color: #ff0000">WpdiscuzHelperAjax</span> </strong>class, it'll help you better understand how the wpDiscuz votes are realised. </p>]]></content:encoded>
						                            <category domain="https://wpdiscuz.com/community/troubleshooting/">How-to and Troubleshooting</category>                        <dc:creator>Asti</dc:creator>
                        <guid isPermaLink="true">https://wpdiscuz.com/community/troubleshooting/can-i-use-wpdiscuz-in-my-theme-function-php-file-in-an-endpoint-to-add-new-vote/#post-13037</guid>
                    </item>
							        </channel>
        </rss>
		