Let a non-editor into wp-admin
Exempt specific people from the subscriber wp-admin redirect, with benecaster_block_subscriber_wpadmin.
Signature: benecaster_block_subscriber_wpadmin( bool $should_block, int $user_id ): bool. Free, never licence-gated. Default true.
Why a recipe rather than a footnote: the condition is capability-based, not Benecaster-based. Benecaster redirects every logged-in user who fails current_user_can( 'edit_posts' ), so on a site where Benecaster sits beside a shop or a forum, those customers and members are redirected to the podcast account page too. That is the specified behaviour, and this filter is the only way out.
Return false to let somebody through. Branch on $user_id (or on roles, or on whether the person actually has a Benecaster token) to exempt a group without switching the redirect off site-wide.
The redirect already exempts logged-out requests, wp_doing_ajax(), wp_doing_cron() and admin-post.php. You do not need to re-check any of those in your callback.
benecaster_get_user_tier_for_show() returns the BASE tier only, and '' for somebody with no active token — which is the test the second example below wants. It is not a buy-up check; see benecaster_user_has_buyup() for that. On a multi-show install there is no equivalent one-call answer, which is why the example bails rather than guessing.
Code
<?php
// Let shop customers keep their WooCommerce account pages in wp-admin,
// while podcast subscribers are still sent to the Benecaster account page.
add_filter(
'benecaster_block_subscriber_wpadmin',
function ( bool $should_block, int $user_id ): bool {
$user = get_userdata( $user_id );
if ( $user && in_array( 'customer', (array) $user->roles, true ) ) {
return false;
}
return $should_block;
},
10,
2
);
// Or, on a single-show site: only redirect people who actually hold a tier
// on that show, and leave every other non-editor alone.
add_filter(
'benecaster_block_subscriber_wpadmin',
function ( bool $should_block, int $user_id ): bool {
$show_id = benecaster_get_sole_show_id();
if ( null === $show_id ) {
return $should_block; // Multi-show install — no single answer.
}
// Returns '' when the user has no active token on that show.
return $should_block
&& '' !== benecaster_get_user_tier_for_show( $show_id, $user_id );
},
10,
2
);
Hooks Used
Need this built rather than just documented? See our services →