Skip to content

Instantly share code, notes, and snippets.

@josephhinson
Last active March 11, 2025 15:25
Show Gist options
  • Save josephhinson/307a318640a20e51c92014d1c4f8dff5 to your computer and use it in GitHub Desktop.
Save josephhinson/307a318640a20e51c92014d1c4f8dff5 to your computer and use it in GitHub Desktop.
If a page uses Beaver Builder to edit the page, the user will not see the "Edit Page" link in the WP Admin Menu Bar
<?php
/**
* Hide the "Edit Page" link in the admin bar on the front end for pages built with Beaver Builder.
*/
function remove_beaver_builder_edit_link() {
// Only run on the front end and for logged-in users.
if ( is_admin() || ! is_user_logged_in() ) {
return;
}
global $post;
// Check that we're on a page and that we have a valid post object.
if ( is_page() && isset( $post->ID ) ) {
// Check if Beaver Builder is enabled on this page.
// Beaver Builder sets the '_fl_builder_enabled' meta when it's active.
$beaver_enabled = get_post_meta( $post->ID, '_fl_builder_enabled', true );
if ( $beaver_enabled ) {
global $wp_admin_bar;
// Remove the "Edit" node from the admin bar.
$wp_admin_bar->remove_node( 'edit' );
}
}
}
add_action( 'wp_before_admin_bar_render', 'remove_beaver_builder_edit_link' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment