Filter
rpress_account_sections
On this page
Filters the sections of the customer account page.
Applied by rpress_account_sections() for the [rpress_customer_dashboard] page. Add, remove or reorder sections. Each section can set label, icon (image URL), endpoint (URL slug, '' for none), callback (prints the section and receives the section ID), visible (bool or a callable returning bool) and legacy_id. The first section is the default one; missing keys get defaults.
Available since RestroPress 3.5.1.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$sections | array | Section ID => section array. Core sections are profile, orders and addresses. |
Return value#
array. Sections in sidebar order.
Example#
add_filter( 'rpress_account_sections', 'my_account_sections', 10, 1 );
function my_account_sections( $sections ) {
$sections['rewards'] = array(
'label' => __( 'Rewards', 'my-plugin' ),
'endpoint' => 'rewards',
'callback' => 'my_render_rewards_section',
'visible' => 'is_user_logged_in',
);
return $sections;
}
function my_render_rewards_section( $section_id ) {
echo '<p>' . esc_html__( 'Your rewards will appear here.', 'my-plugin' ) . '</p>';
}
Notes#
Section URL rewrite rules are registered on init priority 20, so add the filter before then. Rewrite rules are flushed automatically when the set of slugs changes.
Source#
Applied in:
includes/features/account/loader.php(line 65), inrpress_account_sections()
See also#
Was this page helpful?
