Author Archive

Show me your privates- displaying private pages to logged in users

Posted by Mike on Jul 27 2010 | wordpress-mods

WordPress is great. And a lot of people use the free blogging service they supply for writing those cool updates and sarcastic posts bashing the latest Michael Bay film. I, however, run my own version of the blog and use it a little differently than most people.

In fact, a majority of the post I make never make it to the light of day, as most of them are private. The reason I do this is I use WordPress to save a bunch of different things, journal entries, writing prompts, and photos on my site. I have a bunch of pages set up that feedback all the posts matching a certain category (for instance, the “Writing” tab in my header is a collection of all my posts with the writing category. All of that is rather straight forward, but what you don’t know, is that when I log in I see a bunch of extra tabs for private pages up top.

I don’t like the security risk of “password” protected pages, because that lets the public know that something exists. Something I don’t want them to see. So I publish private pages and changed some word press code to display those to logged in users. I should note that I’m the only user that logs into this site, so I can see everything once logged in, there is no need for levels, such as user, contributor, and administrator, but the following code is malleable to that as well.

in $WORDPRESS/wp-include/post.php file

There is a line in the “get_pages” function that looks like this:

$query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish' ) $where ";

Just below that line, add in the following code:

if ( is_user_logged_in() )
{
$query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page' AND (post_status = 'publish' OR post_status='private') ) $where ";
}

UPDATED for wordpress 3.0:

There is a line in the “get_pages” function that looks like this:

$where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status );

Just below that line, add in the following code:

if ( is_user_logged_in() )
	{
	$where_post_type = $wpdb->prepare( "post_type = '%s' AND (post_status = '%s' OR post_status = 'private' )", $post_type, $post_status );
	}

This now checks to see if a user is logged in, and if so, will output private pages to the caller of this function (usually wp_list_pages()).

That’s all there is to it. Be warned, it might will get overwritten during WordPress updates, as I have not gone to version 3.0 yet, and this seems like a feature they’ll add at some point.

no comments for now

Yes man – why saying no is so hard to do.

Posted by Mike on Jul 26 2010 | In All Seriousness, Life of Mike, work

Of the many qualities that described me when I first began work, the one that I see most universally amongst my peers is the inability to say no. I’m not talking about saying no to drugs, or to taking candy from a stranger. No, what I’m referring to is the “can you do it” question that is, for all intents and purposes, unanswerable by someone just starting out. No is such a loaded word when you’re first starting out- is it rejection? Is it disappointment? Is it unexpected? Is it unimaginative? Is it the last word you’ll say at your brand new job?

When I started work, I was asked my professional opinion on a lot of things, most of which I could only respond with “I’ll get back to you.” A good question is usually asked by other engineers or other developers: How do you do this? Did you think about this? Why does it do that? These are questions that I like, they rely on things that I know or have dealt with before. They are ones on which I can draw from my immense (ha!) experience. Compare that to, say, a manger’s question and you can instantly feel the your feet moving- feel that? That’s the earth shaking. It’s a question like “How long will this take you?” or even worse, it’s a question that has the dreaded binary, yes/no answer. “Can you do it”, is by far the worst question a new hire can be asked, and the reasons are all summed up above with those implications we attach to our response.

Or maybe this whole “no” thing comes from confrontation-avoidance. While this is a whole other topic of conversation, my generation has been raised to think they are the most special people in the world, and any dent in this (mentally created)  armor might cause far away universes to die. But I digress.

As a new employee, I was eager to prove myself, as were many of my peers I’ve since talked to about it all, by becoming dependable and have that “get-it-done attitude”. If I said no, I’d be setting limits on my ability too early and without actually knowing what they were. Of course, we should let the answer be the truth, and not let our emotions or view of what that means move us otherwise. If the answer is disappointing, perhaps the question should be rephrased (re-scoped) or maybe they should ask someone who is more qualified, which is sometimes a staggering few people, as it turns out. But I felt I’d be sending a clear message that other people were better suited for certain tasks than I was. I wasn’t about to let that happen, and as it turned out, I got in over my head pretty quickly.

Now, maybe other people inherently have the ability to say no to certain tasks and people, but I wasn’t one of them, but part of me feels, in retrospect, that I shouldn’t have been asked some of these questions. It’s not that the project failed or I didn’t meet my deadlines, but I had to kill myself to do a few of them. At some point, people need to know what new employees don’t know, or at the very least, multiply what they think the effort will be by 2.5 (at least).

I’ve learned my lesson in one respect, I know my time lines a bit better than before. I still think I’m the right person for every job floated my way (this both a product of my self-perceived talent as well as the nature of the “find your own work or you’re out” job market). But it’s hard for me to say no when people ask me to do something- i might say that it’ll take me a while, but I’ll still say I can do it. I want to do it. I still am young and need to prove myself. And maybe I should let me work speak for itself, but the more that’s out there I feel the louder my words will be- and when something is particularly exciting to me, I don’t want to pass it up.

no comments for now

The Past Week

Posted by Mike on Jul 26 2010 | Life of Mike, Photography

I returned from a trip to Sequoia and King’s Canyon National Parks last week, and while ti was a rough week getting back into the groove of things, I’m pretty much back on track and getting a lot done day to day now. I took about 4 gigs of photos on the trip, half of which are probably “throw away” photos, but the other half are keepers, and a select few of them have made it into my personal collection for the trip. You can get a glimpse of my photos in my gallery.

I added these to facebook and got surprisingly few comments on them. Maybe they aren’t that good, or people aren’t interested in them, but either way, I’m coming to realize that facebook is not a place that fosters creating, only sharing. I am sure a certain level of talent can transcend this barrier, but the majority of facebook users want to write/comment/like things that affect them or things they go through, not appreciate the random, unique, or sublime. I’m not upset about this, just need to come to terms with it. Maybe one day i’ll be talented enough to transcend user’s nominal use of sites and shape how they can use them instead.

no comments for now

Something’s Brewing…

Posted by Mike on Jun 02 2010 | Uncategorized

And I’m excited…

no comments for now

Lent began, so give something up you over-indulging biscuits!

Posted by Mike on Feb 19 2010 | Uncategorized

It seems like every famous person has some how codified the rules by which they live their life. In the next couple of days i’m going to start writing again, and i’ll attempt to do the same for me. I’ll probably take one post of laying them all out, and then following them up with more elaborate explanations of each.

And i’m giving up soda and a crappy diet.

no comments for now

Next »