• Resolved Farshad Gohari

    (@fgafarshad75)


    Hi, I get the total points of a user with this code:
    from this doc: https://gamipress.com/snippets/custom-functionalities/gamipress_sum_of_points-shortcode/

    
    function my_prefix_gamipress_sum_of_points_shortcode( $atts ) {
    
        $atts = shortcode_atts( array(
            'points_type' => 'all',
            'user_id' => '0',
            'current_user' => 'no'
        ), $atts, 'gamipress_sum_of_points' );
    
        // Check desired points types
        if( $atts['points_type'] === 'all') {
            $points_types = gamipress_get_points_types_slugs();
        } else {
            $points_types = explode( ',', $atts['points_type'] );
        }
    
        // Force to set current user as user ID
        if( $atts['current_user'] === 'yes' ) {
            $atts['user_id'] = get_current_user_id();
        } else if( absint( $atts['user_id'] ) === 0 ) {
            $atts['user_id'] = get_current_user_id();
        }
    
        $sum_of_points = 0;
    
        foreach( $points_types as $points_type ) {
    
            // Ensure that this points type slug is registered
            if( ! in_array( $points_type, gamipress_get_points_types_slugs() ) ) {
                continue;
            }
    
            $sum_of_points += gamipress_get_user_points( $atts['user_id'], $points_type );
        }
    
        // Return the sum of points of all or specific points types
        return $sum_of_points;
    
    }
    add_shortcode( 'gamipress_sum_of_points', 'my_prefix_gamipress_sum_of_points_shortcode' );
    

    How i can impact time period in this code? for example get the last 7 days points that user awards.

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

    (@rubengc)

    Hi @fgafarshad75

    The [gamipress_points] shortcodes has the ability to display the user points balance of any type based on a time period

    This code snippet is designed to make a sum of all points from the different types of the user but it hasn’t such ability

    The unique way to add it is through a custom development, but we don’t offer custom development services yet

    Anyway, any WordPress custom development agency or freelance can handle it for you

    If you don’t know one, we recommend to check our list of trusted experts that can estimate any type of job for you here:
    https://gamipress.com/customizations/

    Best regards

Viewing 1 replies (of 1 total)
  • The topic ‘Get User Points for a period time’ is closed to new replies.