Adding your own content to the member area
Cashback rules under the history table. A link to your terms in the rail. A payout notice above the form. None of these need a template override — the member area has a slot for each of them.
The slots
Every action below is passed the member's user id.
cbtrkr_account_before
Before everything, outside the account
cbtrkr_account_rail_before_nav
In the rail, under the balance card
cbtrkr_account_rail_after_nav
In the rail, under the navigation
cbtrkr_account_tab_top
At the top of every tab. Also passed the tab's slug
cbtrkr_account_tab_bottom
At the bottom of every tab. Also passed the slug
cbtrkr_account_{tab}_top
At the top of one tab
cbtrkr_account_{tab}_bottom
At the bottom of one tab
cbtrkr_account_after
After everything
The tab slugs are dashboard, history, payouts and referrals, giving names like cbtrkr_account_history_bottom and cbtrkr_account_payouts_top.
Cashback rules under the history
add_action('cbtrkr_account_history_bottom', function () {
echo '<div class="cbtrkr_account_empty">';
echo '<div class="cbtrkr_account_empty_title">Why is my cashback still pending?</div>';
echo '<div class="cbtrkr_account_empty_text">Shops confirm orders on their own schedule — usually 30 to 60 days, and longer for travel. We pay it out as soon as they do.</div>';
echo '</div>';
});Writing this yourself is the right way round. The plugin will not print an approval time next to a member's own order, because the only number it could use is an average across every order that shop has ever reported, and beside one order that reads as a promise. In your own words, on your own page, it is a helpful generalisation.
Payout rules above the form
A terms link in the rail
The rail is a vertical stack, so anything you add there wants to be narrow. On a phone the rail becomes a band across the top and your block travels with it.
One notice on every tab
Note the 10, 2 — the generic pair is passed the slug first and the member second, so a callback that wants the user id must accept both.
Extra detail on an activity row
cbtrkr_account_row_meta filters the middle line of one row. It receives an array of strings, which the row joins with ·, and the row's full data.
The keys on $entry are id, type, date_ts, description, shop (an array of name, logo, url, or null), order_ref, sale_amount_display, available_ts, status_key, status_label, amount, amount_display, is_negative and is_void.
A tab of your own
Register it, then render it:
Your tab gets cbtrkr_account_vouchers_top and cbtrkr_account_vouchers_bottom for free — the dynamic names are built from whichever tab is being shown.
Return the $body you were given whenever the active tab is not yours. Returning your own content unconditionally blanks every other tab on the site.
Reusing the plugin's styling
Your blocks will look like the rest of the account if you borrow its classes:
cbtrkr_account_card
A white card with the standard border and radius
cbtrkr_account_notice
A tinted strip with an accent edge
cbtrkr_account_empty
A tinted panel — the empty-state look, useful for explanations
cbtrkr_account_empty_title / _text
Its heading and body
cbtrkr_account_sec + cbtrkr_account_sec_title
A section heading matching Recent activity
cbtrkr_account_button
The primary button
cbtrkr_account_link
An accent-coloured text link
cbtrkr_account_rules
A tidy bullet list
All of them read the same design tokens as the rest of the plugin, so they follow your accent colour without any work.
Escaping
These are actions that echo, so nothing escapes for you. Run anything from the database or from a member through esc_html(), and anything going into an attribute through esc_attr() or esc_url().
Related
Last updated