The above function looks fine, and I tested it just to be sure. It may be that you don’t like what you’re getting.
It adds user meta to the particular author with key Points
and value 100
, like so:
[Points] => Array
(
[0] => 100
)
On the second publish, it will produce the following:
[Points] => Array
(
[0] => 100
[1] => 100
)
And so on.
If you want any other results, then you’ll need to adjust parameters or create a function to process the results.
For example, if you wanted to “add” 100 points arithmetically every time – so the second publish produces the value “200,” the third “300,” and so on – you’d need to get the user_meta, if any, and then arithmetically add each new value, then update the old value with the sum – not simply programmatically “add” the new value to the array.
Alternatively, you could add whatever values together, or turn them into sub-arrays with additional info (whatever other $post values you wanted to save).