当前用户输入计数器重力形成显示数字

时间:2015-03-01 18:49:40

标签: gravity-forms-plugin

如何只显示从当前登录用户

重力表单提交的短代码的数字
add_filter( 'gform_shortcode_entry_count', 'gwiz_entry_count_shortcode', 10, 2 );
function gwiz_entry_count_shortcode( $output, $atts ) {

    extract( shortcode_atts( array(
        'id' => false,
        'status' => 'total', // accepts 'total', 'unread', 'starred', 'trash', 'spam'
        'format' => false // should be 'comma', 'decimal'
    ), $atts ) );

    $valid_statuses = array( 'total', 'unread', 'starred', 'trash', 'spam' );

    if( ! $id || ! in_array( $status, $valid_statuses ) ) {
        return current_user_can( 'update_core' ) ? __( 'Invalid "id" (the form ID) or "status" (i.e. "total", "trash", etc.) parameter passed.' ) : '';
    }

    $counts = GFFormsModel::get_form_counts( $id );
    $output = rgar( $counts, $status );

    if( $format ) {
        $format = $format == 'decimal' ? '.' : ',';
        $output = number_format( $output, 0, false, $format );
    }

    return $output;
}

0 个答案:

没有答案