Okay
  Public Ticket #2711932
Undefined index: wdtNonce
Closed

Comments

  • Isabel started the conversation

    I tried to implement a filter and even if I keep it simple I run into an error:

    add_filter('wpdatatables_filter_mysql_query', 'table_filtering', 10, 2);

    function table_filtering ($query, $table_id)

    {
      $month = 3;

      if ( $table_id == 18 ) {
        
          $query = 'SELECT tTransactions.`id_transaction`,
                    tTransactions.`transaction_date`,
                    tTransactions.`id_product`
                    FROM tTransactions
                    where month(tTransactions.`transaction_date`)='. $month;
       }

       return $query;
    }

    Notice: Undefined index: wdtNonce in /var/www/.../wdt_ajax_actions.php on line 11


    Seems that I run into an issue with wp_verify_nonce($_POST['wdtNonce']...

    Do you have any hints what I am doing wrong? Unfortunately there are no examples in the developer section of the documentation regarding filters/actions...


    Thanks.

  •  2,572
    Aleksandar replied

    Hello Isabel

    Thank you for your purchase.

    Can you please try with this:

    function table_filtering($query,$table_id ) {
      $month = 3;
      if ( $table_id == 18 ) {
        
          $query = "SELECT tTransactions.`id_transaction`,
                    tTransactions.`transaction_date`,
                    tTransactions.`id_product`
                    FROM tTransactions
                    where month(tTransactions.`transaction_date`)=". $month;
       }
       return $query;
    }
    add_filter('wpdatatables_filter_mysql_query', 'table_filtering',10,2);

    Basically, replace single with double quotes, and move the filter below the function.

    Please let me know if that works.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Isabel replied

    Hi Aleksandar,

    unfortunately it did not change anything. What I understand from the topic I think it is related to the nonce which seems to be lost when changing the query...

    Can you please have a look into the nonce impact? The verify_nonce is failing...


    Notice: Undefined index: wdtNonce in /var/www/.../wdt_ajax_actions.php on line 11

    Seems that I run into an issue with wp_verify_nonce($_POST['wdtNonce']...


    Thanks.


  •  2,572
    Aleksandar replied

    Thanks for your feedback, Isabel.

    I've forwarded the ticket to one of our developers, so he can take a look. As soon as I hear from him, I will let you know.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2,572
    Aleksandar replied

    Hi again Isabel.

    When our developer tested it, it's working fine.

    Issues like this usually occur when there is a conflict either with the theme currently active on your website, or another plugin you have installed.

    Can you please change the theme and see if the issue is resolved? If not, then please deactivate all other plugins except for our plugin, refresh the page where the issue is, and see if it is resolved (it should be). If it is, then start activating other plugins one by one, and after each activation refresh the page to see if the issue reoccurred. Once it does reoccur, you will have found the plugin causing the issue.

    If that doesn't help, it could be a caching issue.

    Please try this hook again:

    function table_filtering($query,$table_id ) {
      $month = 3;
      if ( $table_id == 18 ) {
        
          $query = "SELECT tTransactions.`id_transaction`,
                    tTransactions.`transaction_date`,
                    tTransactions.`id_product`
                    FROM tTransactions
                    where month(tTransactions.`transaction_date`)=". $month;
       }
       return $query;
    }
    add_filter('wpdatatables_filter_mysql_query', 'table_filtering',10,2);


    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables