Title: WPDA: QUERY and $$USER$$ variable
Last modified: May 12, 2022

---

# WPDA: QUERY and $$USER$$ variable

 *  Resolved [rladha](https://wordpress.org/support/users/rladha/)
 * (@rladha)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/)
 * Question:
 * How to get the “WordPress user login” in the Query? $$USER$$ works in the project,
   but not able to get the value in Query Builder.
 * SELECT * FROM WP_USERS WHERE USER_LOGIN =’$$USER$$’
    Query OK, 0 rows affected

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [rladha](https://wordpress.org/support/users/rladha/)
 * (@rladha)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15638839)
 * Addition: I would like to use $$USER$$ when displaying data in Publication.
 *  [measy](https://wordpress.org/support/users/measy/)
 * (@measy)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15639040)
 * Hi there,
    you can refer to $USER$ in the WHERE condition of your template/project:
   it works perfectly at runtime. Hope this help.
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15639328)
 * Hi Rahim, Marco,
 * You can use the $$USER$$ variable in a publication just like a project. However,
   when a anonymous user accesses your publication, $$USER$$ is set to ‘anonymous’.
   You might need to handle this value in your where clause.
 * Does this help?
    Peter
 *  Thread Starter [rladha](https://wordpress.org/support/users/rladha/)
 * (@rladha)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15641077)
 * 1. I found the way to add WHERE Clause in Publication it is working.
    2. But,
   I am finding, Search Panes (Under Premium Extension) doesn’t not take in account
   the WHERE Clause.
 * Example:
    1. I have a list of Cities (TORONTO, MONTREAL, OTTAWA, VANCOUVER) 2.
   Add a WHERE CLAUSE CITY IN (SELECT DISTINCT CITY FROM X WHERE USER_NAME = ‘$$
   USER$$’) 2. USER_1 belongs to TORONTO 3. In Tables, WHERE CAUSED applied, only
   TORONTO is listed 4. But in Search Panes of Cities, it is listing all the CITIES(
   which should also show TORONTO.
 * My application is behind the login, and would like to display data as per user’s
   permission.
 * I hope above make sense.
 * Rahim
 * Proud support of this plug-in and re-newal owner of this Premium Plugins.
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15641720)
 * Hi Rahim,
 * Thank for your explanation. 👍 I see the problem! The search panes query is not
   taking the default where clause into account. Good point! I will add it. Hope
   you have it after the next update.
 * Thank you for your contribution,
    Peter
 *  [measy](https://wordpress.org/support/users/measy/)
 * (@measy)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15653539)
 * Hi Peter/Rahim
    at first sight, it looks to me the same as in my previous topic:
   adding $$USER$$ reference to Lookups (Where condition similar to Page/Template
   ones).
 * Really looking forward to hear good news.
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15655426)
 * Hi Marco,
 * Environment variables are not available in lookups. Sorry! This requires some
   changes in the Data Projects structure. A new Data Forms release is planned to
   give us more freedom in this area…
 * Sorry,
    Peter
 *  [measy](https://wordpress.org/support/users/measy/)
 * (@measy)
 * [4 years ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15657060)
 * Hi Peter,
    thanks for your feedback and.. yes, looking forward to new Data Forms
   release. I simply wished to point out that your valuable Plugin could significantly“
   step forward” if this will be implemented. Regards, Marco
 *  Thread Starter [rladha](https://wordpress.org/support/users/rladha/)
 * (@rladha)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15766209)
 * Hi Peter,
 * Is the fixed part of the latest released?
 *     ```
       Hi Rahim,
   
       Thank for your explanation. 👍 I see the problem! The search panes query is not taking the default where clause into account. Good point! I will add it. Hope you have it after the next update.
   
       Thank you for your contribution,
       Peter
       ```
   
 * Rahim
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15766491)
 * Yes Rahim,
 * It is fixed! Let me know if there are still other issues…
 * Best regards,
    Peter

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘WPDA: QUERY and $$USER$$ variable’ is closed to new replies.

 * ![](https://ps.w.org/wp-data-access/assets/icon-256x256.png?rev=3299063)
 * [WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards](https://wordpress.org/plugins/wp-data-access/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-data-access/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-data-access/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-data-access/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-data-access/reviews/)

 * 10 replies
 * 3 participants
 * Last reply from: [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/wpda-query-and-user-variable/#post-15766491)
 * Status: resolved