Hide Buddypress member pages from non-logged-in users and search engines

Sometimes you need to restrict Buddypress member pages from search engines and/or users who are not logged in. There are a few ways to solve this, but the easiest method is to require users to be logged in to view member pages. To do that, just drop this code into your functions.php file.

function k4media_buddypress_member_pages_login_check() {
	if( bp_is_user() && ! is_user_logged_in() ) {
		auth_redirect();
	}
}
add_action( 'template_redirect', 'k4media_buddypress_member_pages_login_check' ); 

The code is pretty simple. The function bp_is_user() checks to see if the user is viewing a Buddypress member page. The function is_user_logged_in() checks to see if, well, it’s pretty obvious what it checks for, right? The exclamation point means “not”. In human-friendly terms, the line of code reads like this: if the user is viewing a Buddypress member page and the user is not logged in, then auth_redirect(), which is a built-in WordPress function that sends users to the login page.

The Internet in 3D, seriously

It’s not often that something genuinely new comes to the Web. Not new new, anyway. Sure, things evolve, often slowly and usually incrementally. A few years ago the big browsers started supporting javascript in a (mostly) standardized way, and that paved the oxcart trail for point-and-shoot libraries like jQuery and Scriptaculous, which sparked a wave of  awful sliders on top of every other Web site.

But times are changin’. And with more powerful Web browsers, a new generation of HTML, and killer new javascript libraries, full-on 3D is now a reality.

I use a fixed full-screen canvas and sync up scrolling with a 3D camera. The scene is mapped to CSS pixels and CSS perspective is locked to the camera. Once HTML, CSS 3D and WebGL are all in sync there’s a truckload of linear algebra and easing functions to keep you amused. The code is based on the platform I kludged together for the christmas demo, at times a mess of ad hoc demo formulas and spaghetti, though robust enough in the parts that count.

Check out the how-to. It’s jaw-dropping Wow (at least for Web design geeks).

A faster phpThumbs

phpThumbs is a great script for resizing images on the fly. The script lets you create thumbnails or other variations of an original image simply by calling a specially crafted URL.

<img src="../phpThumb.php?src=images/disk.jpg&w=200" alt="">

That line of code will produce a resized version of the original at a width of 200 pixels. Easy as. The only drawback, however, is that phpThumbs can be slow, even with caching.

Mr. Php has a great solution that solves phpThumb’s speed issues. It’s easy to implement and really makes phpThumbs a robust solution for nearly any situation.