Tribe__Events__Community__Main::blockRolesFromAdmin()

Facilitate blocking specific roles from the admin environment.


Source

File: src/Tribe/Main.php

		public function blockRolesFromAdmin() {
			//Get Current User ID
			$user_id = get_current_user_id();

			// Let WordPress worry about admin access for unauthenticated users
			if ( ! is_user_logged_in() ) {
				return;
			}
			//If User Cannot Access Admin Hide the Admin Bar
			if ( ! $this->user_can_access_admin( $user_id ) ) {
				add_filter( 'show_admin_bar', '__return_false' );
			}

			// If it is not an admin request - or if it is an ajax request - then we don't need to interfere
			if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
				return;
			}

			// If the user has access privileges then we don't need to interfere
			if ( $this->user_can_access_admin( $user_id ) ) {
				return;
			}

			// Make sure the action to send the email comes from the FE
			if (
				'email' === tribe_get_request_var( 'action' )
				&& 'tickets-attendees' === tribe_get_request_var( 'page' )
				&& tribe_get_request_var( 'event_id' )
			) {
				return;
			}

			// Redirect user to appropriate location
			wp_safe_redirect( wp_validate_redirect( trailingslashit( $this->blockRolesRedirect ), home_url() ) );
			exit;
		}