Skip to content

Instantly share code, notes, and snippets.

@pingram3541
Created October 26, 2016 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingram3541/831aecf628165b5f36f856303b23b5be to your computer and use it in GitHub Desktop.
Save pingram3541/831aecf628165b5f36f856303b23b5be to your computer and use it in GitHub Desktop.
Elementor content conforms to page assigned Paid Memberships Pro membership levels - /elementor/includes/frontend.php L315
public function apply_builder_in_content( $content ) {
if ( ! $this->_is_frontend_mode )
return $content;
$post_id = get_the_ID();
if ( post_password_required( $post_id ) )
return $content;
$data = Plugin::instance()->db->get_plain_editor( $post_id );
$edit_mode = Plugin::instance()->db->get_edit_mode( $post_id );
if ( empty( $data ) || 'builder' !== $edit_mode )
return $content;
/* custom code to filter paid membership pro */
$hasaccess = pmpro_has_membership_access(NULL, NULL, true);
if(is_array($hasaccess)){
//returned an array to give us the membership level values
//$post_membership_levels_ids = $hasaccess[1]; //gives us all level ids
//$post_membership_levels_names = $hasaccess[2]; //gives us the level names
$hasaccess = $hasaccess[0];
}
if($hasaccess){
ob_start(); ?>
<div id="elementor" class="elementor">
<div id="elementor-inner">
<div id="elementor-section-wrap">
<?php $this->_print_sections( $data ); ?>
</div>
</div>
</div>
<?php
return apply_filters( 'elementor/frontend/the_content', ob_get_clean() );
} else {
ob_start(); ?>
<div id="elementor" class="elementor container">
<div id="elementor-inner">
<div id="elementor-section-wrap">
<div class="pmpro_content_message"><br><br>This content is for GoFit Concepts Monthly Program members only.<br><a href="<?php echo wp_login_url( get_permalink() ) ?>">Log In</a> <a href="<?php echo esc_url( wp_registration_url() ); ?>"><?php esc_html_e( 'Register', 'textdomain' ); ?></a></div>
</div>
</div>
</div>
<?php
return apply_filters( 'elementor/frontend/the_content', ob_get_clean() );
}
}
@pingram3541
Copy link
Author

from functions.php -

add_filter( 'elementor/frontend/the_content', function ( $content ) {
  /****
   * Your if / else or whatever goes here to determine what
   * modifications to $content is necessary or not, then don't
   * forget to return $content
   ************************************/
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment