Take the 2-minute tour ×

I'm (still) working on a custom post type plugin for my workplace and came across an easier method of marking Visitors (my custom post type) as either "Here" (aka checked-in) or "Not Here" (not checked-in).

I've explored the Edit Flow plugin and, to be honest, I can't really follow what all is going on here... I did however come across a function that appears to be in WordPress' core, but I can't seem to find much documentation on the web (none on wordpress.org even). The function is register_post_status but the best I found was this resource which at best only shows me the arguments that go with the function's $args parameter.

Anyone ever tried this? Or am I the only one who's really needed custom post statuses for custom post types?

EDIT: I've read this and this as per the answers/comments I've received. Here is an implementation that I'm not 100% sure about because documentation is lacking.

I know it doesn't work, but I don't get why it doesn't work. Neither of the two statuses show up in the status list. My next course of action is to hack it with a taxonomy and just create my own 'Publish' meta box.

    register_post_status('in', array(
            'label' => _x( 'Logged In', $post_type ),
            'protected' => true,
            'label_count' => _n_noop( 'Visitors logged in <span class="count">(%s)</span>', 'Visitors logged in <span class="count">(%s)</span>' ),
            'show_in_admin_status_list' => true,

    register_post_status('out', array(
            'label' => _x( 'Logged Out', $post_type ),
            'protected' => true,
            'label_count' => _n_noop( 'Visitors logged out <span class="count">(%s)</span>', 'Visitors logged out <span class="count">(%s)</span>' ),
            'show_in_admin_status_list' => true,
share|improve this question
what are you trying to achieve ? way not use custom field or a custom taxonomy? –  Bainternet Jan 20 '11 at 20:14
The problem with either of those is it requires thinking on the end-user. My end-users don't know how wordpress functions at all. –  Zack Jan 20 '11 at 21:28
again what are you trying to achieve? maybe it will help me understand you better –  Bainternet Jan 20 '11 at 23:53
I'm trying to add statuses to "posts" (Visitors) to determine who's currently logged in/here. (No this isn't for WP authentication...) –  Zack Jan 21 '11 at 5:27

2 Answers 2

up vote 6 down vote accepted

Custom post statuses do exist in the core code of WordPress, so you can register them, but they are not yet properly implemented in the admin screens (e.g. they don't show in the dropdown list of statuses alongside Pending Review, Draft, Published). So essentially you can do very little with them at the moment.

You can read more on Trac ticket 12706.

share|improve this answer
Thanks for the info. I'll keep the ticket bookmarked. ;) –  Zack Feb 1 '11 at 20:16

I have done something similar to what facebook does, like where you can post status updates. Similar to what you're trying to do i believe. I just created a custom post type that had the supported the excerpt and title only, to use it for posting the statuses.

The register_post_status is not what you think it is. The post statuses in wp are things like, publish, draft, future (scheduled posts) and locked/private. They are the statuses of your posts. Whether they are published or not, whatever they may be set as.

To show who's currently logged in/out you could use a plugin for that. I recommend this one for example. http://lesterchan.net/portfolio/programming/php/#wp-useronline

You could also create a relatively short script that loops through all registered users, and checks if is_user_logged_in() by their IDs. This wouldn't work to return the users who are logged in, it just loops through all the registered users so you can do stuff with them. You could figure out a way to make it check is_user_logged_in() though somehow I'm sure.

$wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID");

foreach ( $wp_user_search as $userid ) {
    $user_id = (int) $userid->ID;

    /* use this or some other current_user() function in WP to check if user is logged 
share|improve this answer
As per my original question's comments, I am not looking for a way to determine WordPress-users status. I'll just go and hack it them using a taxonomy field and replacing the publish meta box then since no one knows how to do what I asked. :/ –  Zack Jan 30 '11 at 23:35
Oh, well now I guess reading it again, I think I see what you're trying to say. I never really thought of using post_statuses for something that wasn't a type post ,.. status. In otherwords, like what the default ones are. What you want to do is sort of similar but for an entirely different thing so it threw me off. Now thinking bout it, I think that would be a good way to go about it. You could register the post statuses, and then maybe add them to the post meta or something somehow. I'm not sure, I'll have to think more on that. –  jaredwilli Jan 30 '11 at 23:43
register_post_status doesn't seem to do anything and there is no documentation on WP's codex. I guess it's a feature yet to be implemented. –  Zack Jan 31 '11 at 1:21
It definitely does something and has definitely been implemented since 3.0. Here it is in the source of /wp-includes/post.php phpxref.ftwr.co.uk/wordpress/wp-includes/… There is a huge comment explaining it too. –  jaredwilli Jan 31 '11 at 1:30
I've updated my original question with more details that should help. –  Zack Feb 1 '11 at 17:52

Your Answer


