Created
June 18, 2024 09:56
-
-
Save ipokkel/1027f645c20156396fafde8aa1b5d70f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Block the WordPress dashboard for all users that do not have | |
* the administrative 'manage_options' capability. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function block_dashboard_for_non_admins( $block ) { | |
if ( ! current_user_can( 'manage_options' ) && ! wp_doing_ajax() ) { | |
$block = true; | |
} | |
return $block; | |
} | |
add_filter( 'pmpro_block_dashboard', 'block_dashboard_for_non_admins' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment