Created
June 9, 2021 19:15
-
-
Save sc0ttkclark/0d328db9a82c1b819751c18301933528 to your computer and use it in GitHub Desktop.
PMPro compatibility for the Elementor page builder editor screen
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 | |
/** | |
* Maybe turn off the redirect if we are on the Elementor editor screen logged in as someone who can edit the post. | |
* | |
* @param string $redirect_to The URL to redirect to. | |
* | |
* @return string The URL to redirect to. | |
*/ | |
function my_pmpro_elementor_fix_redirect( $redirect_to ) { | |
// Bypass if not logged in or not on Elementor editor screen. | |
if ( ! is_user_logged_in() || empty( $_GET['elementor-preview'] ) ) { | |
return $redirect_to; | |
} | |
// Bypass if they cannot edit this post. | |
if ( ! current_user_can( 'edit_post', get_the_ID() ) ) { | |
return $redirect_to; | |
} | |
// Turn off the redirect if we are on the Elementor editor screen logged in as someone who can edit the post. | |
return ''; | |
} | |
add_filter( 'pmprocpt_redirect_to', 'my_pmpro_elementor_fix_redirect', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment