Jacob Davis
asked 7 years ago

Hello,

I am trying to run PHP code to subtract a value from my database after a user submits a question. But, I cannot seem to find the part of the plugin that is triggered when the question is first submitted. Does anyone know where that is? Also, I am trying to trigger PHP code when a question is clicked on and opened by a user. I need to be able to get the user’s ID for both scenarios so I can update a value in the database.

Thanks for the help

1 Answers
Allen
answered 7 years ago

@jacob Davis : for your question , you can open file : dw-question-answer/inc/actions.php and go to line 439
the function : dwqa_insert_question(), is the function that run when you submit a question.

For the issue : trigger PHP code when a question is clicked on and opened by a user , i think you have to write your own Javascript file and Ajax for wordpress. trigger when the user click to the question. I think it gonna be like that : When you click to an question, you get the question’s ID , include with some action like "user_clicked" then send the AJAX from the Javascript file to your PHP file, end when the PHP file get the Ajax action "user_clicked" , it’ll get the current user login along with the question’s id then saved.

For Ajax you can research here:
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)

Powered by DW Question & Answer Pro