Skip to content
Docs
Get RestroPress

Filter

rpress_user_can_view_receipt

Updated
On this page

Filters whether the current visitor may view an order receipt.

Runs in the receipt shortcode after rpress_can_view_receipt() has decided, and before the guest-session and permission checks. The shortcode attributes include error, price, discount, products, date, notes, payment_key, payment_method and payment_id, plus the id of the payment looked up from the key. Returning false shows the receipt error message.

Parameters#

ParameterTypeDescription
$user_can_viewboolWhether the visitor may view the receipt.
$rpress_receipt_argsarrayReceipt shortcode attributes, as stored in the global.

Return value#

bool. True to allow viewing the receipt.

Example#

function my_user_can_view_receipt( $user_can_view, $receipt_args ) {
	if ( current_user_can( 'view_shop_sensitive_data' ) ) {
		return true;
	}
	return $user_can_view;
}
add_filter( 'rpress_user_can_view_receipt', 'my_user_can_view_receipt', 10, 2 );

Source#

Applied in:

  • includes/class-rpress-shortcodes.php (line 169), in RP_Shortcodes::rpress_receipt()

See also#

Was this page helpful?