We're Moving to a New Support Platform – Starting June 1st!

We’re excited to let you know that starting June 1st, we’ll be transitioning to a new support system that will be available directly on our product websites – Amelia, wpDataTables, and Report Builder. In fact, the new support platform is already live for Amelia and wpDataTables, and we encourage you to reach out to us there.

You'll always be able to reach us through a widget in the bottom right corner of each website, where you can ask questions, report issues, or simply get assistance.

While we still do not offer live support, a new advanced, AI-powered assistant, trained on our documentation, use cases, and real conversations with our team, is there to help with basic to intermediate questions in no time.

We're doing our best to make this transition smooth and hassle-free. After June 1st, this current support website will redirect you to the new "Contact Us" pages on our product sites.

Thanks for your continued support and trust – we’re excited to bring you an even better support experience!

Okay
  Public Ticket #2594983
Dynamic variables in shortcode
Closed

Comments

  •  1
    Daniel started the conversation

    Hi,

    we've been trying a new use-case recently and it requires some date ranges to be passed in the SQL request, in a way that cannot be solved by the regular filter function in the plugin.

    I know it is possible to pass on filter data via the URL (with ?wdt_column_filter) but I was wondering if you could do the same with the placeholder variables.

    I also know that you can set the variables in the table shortcode, but those can't easily be changed by the user.

    Is it possible to adjust the variables by user input?

    Kind regards,

    Daniel

  •  2,576
    Aleksandar replied

    Hello Daniel

    Well we dont have this built in function, but you can try next but you will need some experiance with writing SQL queries and using WP hooks.

    You can create table with query for example

    SELECT 
    user_id, 
    user_name, 
    user_address,
    CONCAT('<a href="http:/yoursite.com/your_custom_page?user_id=',user_id,'">Details</a>') AS Details
    FROM your_table_name

    and then on your_custom_page you will insert shortcode of the tableid that you need with placeholder like this

    [wpdatatable id=1 var1=1]

    of course, you will create that second table from query like

    SELECT * FROM second_table WHERE user_id = %VAR1%

    and then you will use our hook for dynamic upsetting placeholders

    function updateVAR1($tableID){  global $wdtVar1;      //check is set GET parametar user_id
        if(isset($_GET['user_id'])){
            //get value from form fieald
            $wdtVar1 = $_GET['user_id'];
        }  }
    add_action('wpdatatables_before_get_table_metadata', 'updateVAR1');

    Like this I believe you will get result like you need.

    For user inputs, or the form, or whatever you want to achieve, you would need to create a custom logic so when a user enters something in that input field, or when they click on Submit, to create that GET parameter with the values for the placeholder, which will be replaced in the hook.

    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