Okay
  Public Ticket #867917
Fatal error: Call to a member function setFilterType() on a non-object in
Closed

Comments

  •  1
    Sam started the conversation

    Hi there,

    I'm trying to use the wpdatatables_filter_mysql_query filter with this simple piece of code:

    function show_praktisch_team ($query, $table_id) {
     $teamcodesl = getteamcode();
     $query = "SELECT * FROM wp_wpdatatable_2 WHERE wdt_ID = '1'";
     echo $query;
     return $query;
    }
    add_filter('wpdatatables_filter_mysql_query', 'show_praktisch_team',1,2);

    When executing this code, the next error appears:

    Fatal error: Call to a member function setFilterType() on a non-object in /home/ascnieuwland.nl/public_html/wp.ascnieuwland.nl/wp-content/plugins/wpdatatables/source/class.wpdatatable.php on line 1725

    I guess I'm using the wrong syntax for the SQL query, but I can not find any documentation on the correct syntax. Could you please help?

    Thanks in advance!

    Cheers,

    Sam

  • [deleted] replied

    Hi Sam,
    Thank you for your purchase.

    Please send me temporary login credentials of your website so I can take a look. You can write them here just mark replay as private so nobody can see it. 

  •  1
    Sam replied

    Hi Milos,

    Thanks for the quick response. Just half an hour ago I managed to solve the problem. Re-creating the table and using a proper syntax for the SQL query did the tric. Apologies for opening this ticket, it can be closed!

    However, I have another issue when using 2 tables on 1 page, it looks like the wpDataTables filter applies to both of them. Should I open a separate ticket for that?

    Cheers,

    Sam

  • [deleted] replied

    Hi Sam,

    No need for opening new ticket. Great that you have resolved issue.

    You can add condition because you have $table_id as a parameter to apply function just for that table. e.g.

    if ( $table_id == 2 ) {
        $query = "SELECT * FROM wp_wpdatatable_2 WHERE wdt_ID = 1";
        return $query;
    }
  •  1
    Sam replied

    Hi Milos,

    Thanks a lot; life can be so simple :-). Should have thought of that solution myself. Everything is clear for now, thanks again for your help!

    Cheers,

    Sam

  • [deleted] replied

    Hi Sam,

    You are welcome. If you are satisfied with our plugin and support please rate our plugin on CodeCanyon on this link. It means a lot to us. Thanks.