• Resolved achristmann

    (@achristmann)


    I’m trying to pull an SQL value based on the user name. I’ve created a report that functions perfectly but I need to insert a single value into a table. I’m using the shortcode:

    [sqlgetvar]SELECT enterprise FROM wp_users WHERE user_login='<?php $current_user->user_login?>'[/sqlgetvar]

    I’m really not sure what I’m missing.

    Awesome plugin. I thank you for your support.

    https://www.ads-software.com/plugins/elisqlreports/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Eli

    (@scheeeli)

    If enterprise is a column that you have added the the wp_users table then, yes, that query should work.

    However, if enterprise is a meta_key that is stored in the wp_usermeta table then your query should look like this:

    SELECT meta_value FROM wp_usermeta WHERE meta_key = ‘enterprise’ AND user_id='<?php $current_user->ID?>’ LIMIT 1

    Let me know if that helps or not. If you are still having trouble with it and you are willing to give me direct access to your WP Admin, I would be happy to take a look at it.

    Thread Starter achristmann

    (@achristmann)

    Yes, enterprise is a column in the wp_users table but the query does not seem to work. Happy to provide admin login info. Where should I send it?

    Plugin Author Eli

    (@scheeeli)

    You can send WP Admin login info to my email: wordpress AT ieonly DOT com

    Thread Starter achristmann

    (@achristmann)

    Thanks. Emailed the information over to you.

    Plugin Author Eli

    (@scheeeli)

    Thanks for the login. I debugged the query on your site and although there was a strange syntax error on some of the “spaces” between the words in your query the main problem was the my sqlgetvar shortcode did not have the eval code in it to interpret the global variable you were trying to use.

    I fixed the code in my plugin on your site and I will release an update with that bug-fix soon. I also changed you query a bit and fix the invalid characters. Watch out when you use “<” and “>” symbols in the WP editor that they do not get turned into “& lt ;” and “& gt ;”. I think it should all be working for you now. Please let me know if I missed anything.

    Aloha, Eli

    Thread Starter achristmann

    (@achristmann)

    Looks like it’s working like a charm. Thank you very much for all your help. I’ve made a donation to your plugin as well.

    Plugin Author Eli

    (@scheeeli)

    Thank! Let me know if there is anything else.

    Aloha, Eli

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘SQL Report Works But [sqlgetvar] Does Not’ is closed to new replies.