HEX
Server: Apache
System: Linux ecngx285.inmotionhosting.com 4.18.0-553.79.1.lve.el8.x86_64 #1 SMP Wed Oct 15 17:59:35 UTC 2025 x86_64
User: zeusxp5 (3862)
PHP: 8.3.28
Disabled: NONE
Upload Files
File: /home/zeusxp5/chuair.org/paid-memberships-pro.php.tar
zenoxpressalongside.net/wp-content/themes/zxldfw-tcompanyllcMain/functions/paid-memberships-pro.php000064400000011173151243224430032537 0ustar00home/zeusxp5<?php
/**
 * Plugin Name: Paid Memberships Pro Fixes
 * Plugin URI: http://www.web.com
 * Description: Set of functions to correct issues and to enhanace the ACW protected content product.
 * Author: Web.com
 * Author URI: http://www.web.com
 * Version: 1.0
 *
 * @package WebcomAcwTheme
 */

//Fix for Paid Memberships Pro & Page Builder
function fix_pmpro_pb_priorities() {
	remove_filter( 'the_content', 'pmpro_membership_content_filter', 5 );
	add_filter( 'the_content', 'pmpro_membership_content_filter', 11 );
}
add_action('init', 'fix_pmpro_pb_priorities', 20);

/** Custom Login Widget **/
function webcom_widgets() {

	/* Login Widget */
	class web_login extends WP_Widget {

		function web_login() {
			parent::__construct( 'web_login', 'Login Form', array( 'description' => 'Form to allow you to log into your WordPress Blog', ) );
		}

		function widget( $args, $instance ) { 
			if(isset($_GET['redirect_to'])) {
				$redirect_to = $_GET['redirect_to'];
			} else {
				$redirect_to = get_home_url();
			}
			?>

			<aside id="web-login-2" class="widget widget-web-login">

				<?php if (!is_user_logged_in()) { ?>
					<h3 class="widget-title">Login</h3>
					<?php wp_login_form(array('redirect' => $redirect_to)); ?>
				<?php } else { ?>
					<h3 class="widget-title">Account</h3>
					<a href="<?php echo get_admin_url(); ?>">Dashboard</a><br>
					<a href="<?php echo wp_logout_url(get_home_url()); ?>">Logout</a>
				<?php } ?>

			</aside>

		<?php }
	}
	register_widget( 'web_login' );

}
add_action( 'widgets_init', 'webcom_widgets' );

//Remove WP admin bar for subscribers
add_action('set_current_user', 'cc_hide_admin_bar');
function cc_hide_admin_bar() {
  if (!current_user_can('edit_posts')) {
	show_admin_bar(false);
  }
}

// Limiting Access to WordPress Dashboard to Admins.
add_action( 'admin_init', 'admin_area_for_manage_options_only' );
function admin_area_for_manage_options_only() {

    if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
        //Allow ajax calls.
        return;
    }

    if( ! current_user_can( 'manage_options' ) ) {
        // Redirect to main page if the user has no "manage_options" capability.
        wp_redirect( get_site_url() );
        exit;
    }
}

//Allows site admins to edit users assigned to their website
function mc_admin_users_caps( $caps, $cap, $user_id, $args ){

	foreach ( $caps as $key => $capability ) {

		if( $capability != 'do_not_allow' )
			continue;

		switch ( $cap ) {
			case 'edit_user':
			case 'edit_users':
				$caps[ $key ] = 'edit_users';
				break;
			case 'delete_user':
			case 'delete_users':
				$caps[ $key ] = 'delete_users';
				break;
			case 'create_users':
				$caps[ $key ] = $cap;
				break;
		}
	}

	return $caps;
}
add_filter( 'map_meta_cap', 'mc_admin_users_caps', 1, 4 );
remove_all_filters( 'enable_edit_any_user_configuration' );
add_filter( 'enable_edit_any_user_configuration', '__return_true' );

/**
 * Checks that both the editing user and the user being edited are
 * members of the blog and prevents the super admin being edited.
 */
function mc_edit_permission_check() {
	global $current_user, $profileuser;

	$screen = get_current_screen();

	get_currentuserinfo();

	if( ! is_super_admin( $current_user->ID ) && in_array( $screen->base, array( 'user-edit', 'user-edit-network' ) ) ) { // editing a user profile
		if ( is_super_admin( $profileuser->ID ) ) { // trying to edit a superadmin while less than a superadmin
			wp_die( 'You do not have permission to edit this user.' );
		} elseif ( ! ( is_user_member_of_blog( $profileuser->ID, get_current_blog_id() ) && is_user_member_of_blog( $current_user->ID, get_current_blog_id() ) )) { // editing user and edited user aren't members of the same blog
			wp_die( 'You do not have permission to edit this user.' );
		}
	}

}
add_filter( 'admin_head', 'mc_edit_permission_check', 1, 4 );


add_filter( 'editable_roles', 'exclude_editor_role' );
function exclude_editor_role($roles) {
	if (current_user_can('administrator')) {
	   return $roles;
	}
	if (isset($roles['administrator'])) {
	  unset($roles['administrator']);
	}

	return $roles;
}

/** Hide Administrator From User List **/
function isa_pre_user_query($user_search) {
  $user = wp_get_current_user();
  if (!current_user_can('administrator')) { // Is Not Administrator - Remove Administrator
	global $wpdb;

	$user_search->query_where = 
		str_replace('WHERE 1=1', 
			"WHERE 1=1 AND {$wpdb->users}.ID IN (
				 SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta 
					WHERE {$wpdb->usermeta}.meta_key = '{$wpdb->prefix}capabilities'
					AND {$wpdb->usermeta}.meta_value NOT LIKE '%administrator%')", 
			$user_search->query_where
		);
  }
}
add_action('pre_user_query','isa_pre_user_query');