• Resolved josemygel

    (@josemygel)


    The shortcode gamipress_earnings not show points, i am using the next function:
    – gamipress_award_points_to_user($user_id, $points, $points_type, [‘reason’ => ‘Points by…’]);

    And when i use [gamipress_earnings] this awards appear in [gamipress_logs] but not in this shortcode…

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Ruben Garcia

    (@rubengc)

    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!

    Thread Starter josemygel

    (@josemygel)

    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… =(

    Thread Starter josemygel

    (@josemygel)

    @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(
          //...
        ) );
    Thread Starter josemygel

    (@josemygel)

    Okey, not working…

    Points Award, POINT_TYPE’ not appear in list, and in shorcode not apprear too…

    Plugin Author Ruben Garcia

    (@rubengc)

    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.
    Thread Starter josemygel

    (@josemygel)

    The example work correctly, you are a pro =)
    Thanks, i mark as fix it!

    • This reply was modified 3 years ago by josemygel.
    Plugin Author Ruben Garcia

    (@rubengc)

    You’re welcome @josemygel

    Have a great day!

    Plugin Author Ruben Garcia

    (@rubengc)

    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 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcode [gamipress_earnings] not show points’ is closed to new replies.