Detect users input values from any wordpress form

I’m trying to develop a wordpress plugin, I need to get users input data from any form in a specific page (not knowing its action) I come up so far with this solution which is to get values using javascript and then passing it to php:

jQuery(function ($) {
        $( "form" ).submit(function( event ) {
        if($( "form" ).valid()){
            var inputs = $( "form input" );
            var inputValues = [];
                if($(this).attr('type') !== 'submit')


I tried to pass the Javascript variable inputValues to my plugin using Ajax

  type: 'POST',
  url: '../wp-content/plugins/myplugin/myplugin.php',
  data: {'variable': inputValues},

But I get problems with the url for some pages and I couldn’t use $_POST[‘variable’] in myplugin.php file.
Is there a way to accomplish what I’m trying to do, or do you know an alternative solution?
Thanks in advance.

Read more here: Detect users input values from any wordpress form

Leave a Reply

Your email address will not be published. Required fields are marked *