Okay
  Public Ticket #2710679
New entry by user
Closed

Comments

  • Donny Lairson started the conversation

    I created a test account. I have tried to follow video's.

    I have a CUSTOM table in my wordpress database. 

    So the table you see in link is NOT gathering the Current user ID and using it to insert data.  If all the fields are filled out it will insert data.

    But as you will be able to tell with a free account it won't draw the table information back up because its selected by %current_user_id% and a new entry is blank.

  • Donny Lairson replied

    INSERT INTO wp_1_users_stats.`rrg_id`
    SELECT ‘%CURRENT_USER_ID%’
    WHERE NOT EXISTS (
    SELECT wp_1_users_stats.`castle_level`,
    wp_1_users_stats.`rrg_id`,
    wp_1_users_stats.`in_game_name`,
    wp_1_users_stats.`Kingdom`,
    wp_1_users_stats.`alliance_tag`,
    wp_1_users_stats.`airship_level`, 
    wp_1_users_stats.`march_capacity`
    FROM wp_1_users_stats WHERE wp_1_users_stats.`rrg_id` = '%CURRENT_USER_ID%')


    I tried to correct the problem before the request of table information but INTO is not implemented error came up.

  • Donny Lairson replied

    Adding current user id to the predefined values field did not actually produce that predefined value so that a new entry could be be made.

  •  2,507
    Aleksandar replied

    Hello Donny

    %CURRENT_USER_ID% placeholder can only be used from within wpDataTables, and the plugin doesn't support the query that looks like this:

    INSERT INTO wp_1_users_stats.`rrg_id`
    SELECT '%CURRENT_USER_ID%'
    WHERE NOT EXISTS (
    SELECT wp_1_users_stats.`castle_level`,
    wp_1_users_stats.`rrg_id`,
    wp_1_users_stats.`in_game_name`,
    wp_1_users_stats.`Kingdom`,
    wp_1_users_stats.`alliance_tag`,
    wp_1_users_stats.`airship_level`, 
    wp_1_users_stats.`march_capacity`
    FROM wp_1_users_stats WHERE wp_1_users_stats.`rrg_id` = '%CURRENT_USER_ID%')

    INSERT INTO can only work in the database.

    So, if you use the query:

    SELECT wp_1_users_stats.`castle_level`,
    wp_1_users_stats.`rrg_id`,
    wp_1_users_stats.`in_game_name`,
    wp_1_users_stats.`Kingdom`,
    wp_1_users_stats.`alliance_tag`,
    wp_1_users_stats.`airship_level`, wp_1_users_stats.`march_capacity`
    FROM wp_1_users_stats WHERE wp_1_users_stats.`rrg_id` = %CURRENT_USER_ID%

    And if rrg_id contains the ID of the currently logged in user, it should display the correct data.

    Also, when using SQL queries in wpDataTables, please refer from using accent graves ( ` ), so since the data is being pulled from a single table, you can use this:

    SELECT castle_level,
            rrg_id,
            in_game_name,
            Kingdom,
            alliance_tag,
            airship_level, 
            march_capacity
    FROM wp_1_users_stats 
    WHERE rrg_id = %CURRENT_USER_ID%


    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