• Resolved simphiwecharles

    (@simphiwecharles)


    Hi,
    i love your plugin. but i have got a bit of a problem, i couldn’t display data (mysql) based on / or specific to the person logged in.

    if possible, please help me out. I am trying to do something like this.

    SELECT * FROM users WHERE ID = CURRENT_USER

    Maybe my syntax is wrong or i just don’t know the right placeholders to use. either way, your help will be appreciated.

    kind regards.
    Simphiwe

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Ian Sadovy

    (@iansadovy)

    Hello Simphiwe,

    Thank you for the question.
    I see that this feature is quite needed, so I just have added it to the WPTables 1.3.7.
    Please update and try predefined variable $user_id as following:
    SELECT * FROM users WHERE ID = $user_id
    Also, you can use wptables_mysql_query filter to modify MySQL query in your own way using PHP.

    Please let me know if it helps you.

    Regards,
    Ian

    Thread Starter simphiwecharles

    (@simphiwecharles)

    Hi Ian

    i did try $user_id but im getting an error Invalid query. Please check the syntax and try again.

    and another thing, where can i modify the mysql filter?

    kind regards,
    Simphiwe

    Plugin Author Ian Sadovy

    (@iansadovy)

    Hello Simphiwe,

    Have you updated the WPTables to the latest version?
    Here is how I do this with my setup – http://take.ms/CeKoq

    Please let me know if it works for you.

    Regards,
    Ian

    Thread Starter simphiwecharles

    (@simphiwecharles)

    Hello Ian,

    I do have the latest version of WPTable, and here is my setup. – http://take.ms/laFQg

    I hope it is helpful because I am really confused right now.

    Kind regards,
    Simphiwe

    Plugin Author Ian Sadovy

    (@iansadovy)

    Thanks for the video.
    Looks really strange. Could you please try this simple query?
    SELECT * FROM wpje_give_donors WHERE id = $user_id
    Maybe there is some conflict with user_id field in the SELECT.

    Look forward to hearing from you.

    Ian

    Thread Starter simphiwecharles

    (@simphiwecharles)

    Good day,

    I tried that query and afraid to say, but i got the same error. I’m really confused now.

    Thank you for trying to help, though. 🙁

    regards,
    Simphiwe

    Plugin Author Ian Sadovy

    (@iansadovy)

    Simphiwe,

    Thank you for the answer and sorry for the trouble.
    Seems I have finally found the error and already published a fix.
    Please update WPTables to 1.3.8 and let me know if it works well now.

    Regards,
    Ian

    Thread Starter simphiwecharles

    (@simphiwecharles)

    Good day,

    It sort of works now but there is one slight problem, when the data is queried from the database and displayed on the table, it is some how wrong. user-1’s data is displayed when user2 is logged in. same story if i login with the other user. But i think we are really close now to find the solution.

    secondly, please correct me if I am wrong, but $user_id has to do with access control (admin, contributor, etc). So, wouldn’t it maybe work better if used ID(on the first column, which is auto-incremented). at that case it will always be unique to that particular person. link – http://take.ms/viPht

    I hope I am not causing too much unnecessary work for you.

    Kind regards,
    Simphiwe

    Plugin Author Ian Sadovy

    (@iansadovy)

    Glad to hear it works.
    Actually, $user_id is replaced with current WP User ID (get_current_user_id). From your table I see that id is a primary key for wpje_give_donors table (not a user id). And user key associated with this record is user_id. So, changing your query as following may help:
    ... WHERE user_id = $user_id

    Hope it helps.

    Regards,
    Ian

    Thread Starter simphiwecharles

    (@simphiwecharles)

    Good day,

    Thank you so so much, it finally works as expected. I’m so excited. I’m gonna give your work all the stars. I will also do some recommendation.

    Kind regards,
    Simphiwe

    Plugin Author Ian Sadovy

    (@iansadovy)

    Hi Simphiwe,

    Glad to hear that, thank you!

    Regards,
    Ian

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘access control and viewing’ is closed to new replies.