Hi @josemygel
The gamipress_award_points_to_user() only updates the user meta but does not creates the user earning
If you want to create the user earning you need to use the function gamipress_insert_user_earning( $user_id = 0, $data = array(), $meta = array() )
Hope this helps!
Hi Ruben!
Thanks, but not working…
With gamipress_insert_user_earning i can see the points in the tab of log in admin, but the shortcode dont show it… =(
@rubengc i finally fix it!
The function need the point_id, maybe you could fix it with next code… Is only a idea ^^
/includes/functions/user-earnings.php
//ADDING
if(isset($data)){
if(isset($data['points_type'] && !isset($data['post_id']))
$data['post_id'] = gamipress_get_points_type_id($data['points_type']);
else if(isset($data['post_id'] && !isset($data['points_type']))
$data['points_type'] = //get_type...
// Post data
$data = wp_parse_args( $data, array(
//...
) );
Okey, not working…
‘Points Award, POINT_TYPE’ not appear in list, and in shorcode not apprear too…
Hi @josemygel
Here is a example:
$user_id = 1;
$points = 100;
$points_type = 'your-points-type-slug';
gamipress_insert_user_earning( $user_id, array(
'title' => 'The earning description',
'user_id' => $user_id,
'post_id' => gamipress_get_points_type_id( $points_type ),
'post_type' => 'points-type',
'points' => $points,
'points_type' => $points_type,
'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
) );
-
This reply was modified 3 years ago by Ruben Garcia.
-
This reply was modified 3 years ago by Yui.
The example work correctly, you are a pro =)
Thanks, i mark as fix it!
-
This reply was modified 3 years ago by josemygel.
You’re welcome @josemygel
Have a great day!
Ah, I forgive to mention that we are a Spanish team, so for future doubts you can open any ticket in Spanish if you wish 🙂