Skip to content
Docs
Get RestroPress

Action

rpress_{$key}

Updated
On this page

Fires for a request that carries an rpress_action parameter, with the action name appended to the hook.

A callback on init reads rpress_action from the query string (rpress_get_actions) or from the posted form (rpress_post_actions) and fires rpress_ followed by that value, for example ?rpress_action=my_export fires rpress_my_export. GET requests pass the raw $_GET array; POST requests pass the sanitized $_POST array.

Parameters#

ParameterTypeDescription
$dataarrayRequest data: $_GET for query-string actions, or the sanitized $_POST for posted actions.

Example#

function my_handle_export( $data ) {
	if ( ! isset( $data['my_nonce'] ) || ! wp_verify_nonce( $data['my_nonce'], 'my_export' ) ) {
		return;
	}
	if ( ! current_user_can( 'manage_shop_settings' ) ) {
		return;
	}
	// Export logic goes here.
}
add_action( 'rpress_my_export', 'my_handle_export' );

Notes#

The dispatcher performs no nonce or capability check. Handlers must verify both. GET data is not sanitized before it is passed.

Source#

Fired from:

  • includes/rp-actions.php (line 24), in rpress_get_actions()
  • includes/rp-actions.php (line 39), in rpress_post_actions()
Was this page helpful?