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

    (@scheeeli)

    I’m not sure what exactly you are trying to change. Can you be more specific about what you are trying to accomplish?

    Maybe include the SQL statement you have so far…

    Thread Starter RuneMarket

    (@runemarket)

    i want to be able to update the users value of a column e.g. balance, I’ve tried using this but can’t get it to work –
    SELECT display_name,BalanceGP FROM wp_users UPDATE table SET BalanceGp = BalanceGP + 1 WHERE ID = 11

    Plugin Author Eli

    (@scheeeli)

    Ok, so first thing is that there is no such field as BalanceGP in the wp_users table, unless you added it. I’m not sure why you would hard-code the ID value in the WHERE clause to 11 but we should address that last, after everything else is working.

    Try this query just to see if you get the values your are looking for:
    SELECT display_name,BalanceGP FROM wp_users WHERE ID = 11

    Assuming you actually have a BalanceGP field in the wp_users table you could maybe accomplish what you want with two queries, entered together, like this:
    UPDATE wp_users SET BalanceGP = BalanceGP + 1 WHERE ID = 11;
    SELECT display_name,BalanceGP FROM wp_users WHERE ID = 11

    Thread Starter RuneMarket

    (@runemarket)

    Sorry I forgot to mention i added BalanceGP to wp_users ?? The First bit didn’t work but then i used this – SELECT display_name,BalanceGP FROM wp_users WHERE ID = ‘<?php $current_user->ID ?>’ It is now showing. This is probably the stupidest way to do it but what i’m trying to achieve is when a user has paid for something it updates the balance P.s I’m really new to coding xD

    Plugin Author Eli

    (@scheeeli)

    Cool, I’m glad you got it working.

    You should be careful about where you put that UPDATE query though. For example, if the payment conformation page executes that UPDATE query and they refresh that page then it may execute the query again, causing it to log a double payment.

    You may need to re-think how you are keeping track of payments all-together. Maybe there is a plugin out there that will do just what you want without hacking up your core WP Tables, that way you don’t have to re-invent the wheel ??

    Good luck!

    Aloha, Eli

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Updating Columns For Current User ID’ is closed to new replies.