• Resolved vuittonfr

    (@vuittonfr)


    Hi Alex, thanks for all of your effort! I have been reading through your documentations and forum threads and have gained lots of value, appreciate your time on this and you’re the man!

    I was wondering if it was possible to export all user’s balance? Ideally, to export all users balance in realtime that is stored Google Sheets?

    The use case is to export all users balance and add a calculation to the field and display the calculated total to the individual user.

    Unless there is another workaround I have missed in the documentation.

    Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author dashed-slug.net

    (@dashedslug)

    Hello and thanks for your kind words!

    The instructions below are for the current versions of wallets (before wallets6):

    1. It is currently possible to export user balances into .csv from the adapters list, but you have to do it one coin at a time. Go to WalletsAdapters Your coin → Export.

    2. If you prefer, you can run your own SQL query. Assuming that your WordPress db prefix is db_:

    
    	SELECT
    		u.ID as user_id,
    		u.user_login AS account_name,
    		u.user_email,
    		t.symbol,
    		SUM( IF( t.amount > 0, t.amount - t.fee, t.amount ) ) AS balance
    
    	FROM
    		wp_wallets_txs
    		LEFT JOIN wp_users u ON u.ID = t.account
    
    	WHERE
    		t.status = 'done'
    
    	GROUP BY
    		t.account,
    		t.symbol
    
    	ORDER BY
    		t.symbol,
    		u.ID ASC;

    But be careful: IF you are on a multisite installation, AND the plugin is NOT network activated, then you also need to filter by blog_id=N in your WHERE clause. N being the number of the site where the plugin is installed. Usually this will not be needed.

    Hope this helps.

    Note that in the upcoming wallets6 release, the SQL tables will be replaced with CPTs, so the SQL query won’t work. But there will be a simple PHP helper function that returns all the user balances.

    Thread Starter vuittonfr

    (@vuittonfr)

    Thanks for this! Do you know if it’s possible to automate the exports daily or when theres a change? Want to use the data to give a new balance total.

    When are you looking to release wallet6?

    Plugin Author dashed-slug.net

    (@dashedslug)

    Hello,

    You can call the above code via a linux cron job on your server. There’s multiple ways to do this.

    The release is only weeks away, possibly less. I am currently doing integration testing and have already tested 7 out of 9 components. For more details on the upcoming release, see here and here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Export User Balance to CSV’ is closed to new replies.