77/**
88 * @link https://www.advancedcustomfields.com/resources/how-to-hide-acf-menu-from-clients/
99 */
10- add_filter ( 'acf/settings/show_admin ' , 'demo_acf_show_admin ' );
10+ add_filter ( 'acf/settings/show_admin ' , 'demo_acf_show_acf_admin ' );
11+ /**
12+ * Filters the settings to pass to the block editor for all editor type.
13+ * @link https://developer.wordpress.org/reference/hooks/block_editor_settings_all/
14+ */
15+ add_filter ( 'block_editor_settings_all ' , 'demo_acf_restrict_locking_ui ' , 10 , 2 );
1116
1217/**
1318 * Allow access to ACF screens by WP user role
1419 * AND a list of allowed email domains.
1520 *
1621 * @link https://developer.wordpress.org/reference/functions/current_user_can/
1722 *
18- * @param boolean $show Whether to show the ACF admin.
1923 * @return boolean $show Whether to show the ACF admin.
2024 *
2125 * @since 0.1.2
2226 */
23- function demo_acf_show_admin ( $ show ) {
27+ function demo_acf_show_admin () {
2428 // If our user can manage site options.
2529 if ( current_user_can ( 'manage_options ' ) ) {
2630 $ user = wp_get_current_user ();
@@ -34,7 +38,9 @@ function demo_acf_show_admin( $show ) {
3438 // Make sure we have a WP_User object and email address.
3539 if ( $ user && isset ( $ user ->user_email ) ) {
3640 // Trim user email to domain only.
37- $ email_domain = strtolower ( array_pop ( explode ( '@ ' , trim ( $ user ->user_email ) ) ) );
41+ $ email_domain = trim ( $ user ->user_email );
42+ $ email_domain = explode ( '@ ' , $ email_domain );
43+ $ email_domain = strtolower ( array_pop ( $ email_domain ) );
3844
3945 // Compare current logged in user's email with our allow list.
4046 if ( in_array ( $ email_domain , $ allowed_email_domains , true ) ) {
@@ -43,3 +49,16 @@ function demo_acf_show_admin( $show ) {
4349 }
4450 }
4551}
52+
53+ /**
54+ * Restrict access to the locking UI to designated email domains.
55+ *
56+ * @param array $settings Default editor settings.
57+ *
58+ * @since 0.1.3
59+ */
60+ function example_theme_restrict_locking_ui ( $ settings ) {
61+ $ settings ['canLockBlocks ' ] = demo_acf_show_admin ();
62+
63+ return $ settings ;
64+ }
0 commit comments