I am working with a heavily customized install of WP. I’ve set up a specific post type, taxonomy, and roles that gets to use just that post type.
Ideally, I’d like to restrict members of that role using that post type to only create one post. This seems like it might be more trouble than it’s worth. So barring that, I’d like to display only the oldest of their posts in an archive view.
I’ve got the following, which creates a workable archive loop, but I haven’t figured out the “if number of posts > 1 then show only oldest post” bit.
$args = array
('post_type' => 'ticketlisting',
'posts_per_page' => 50,
'tax_query' => array
(array
(
'taxonomy' => 'tier',
'field' => 'slug',
'terms' => 'goldstar'
)
)
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
$post_id = get_the_ID();
/* show post content here */
echo '</div>';
endwhile;
To restrict users to just one post, donât let them create new posts. Just add one
wp_editor()
instance to their profile.'show_user_profile'
and'edit_user_profile'
to show the editor.'personal_options_update'
and'edit_user_profile_update'
to save the content to a user meta or a hidden custom post type.Now they donât have to search and they cannot create new posts.
Update
To illustrate what I mean, I refreshed an old plugin:
You have to add the language files by yourself (or I put it on GitHub if somebody is interested enough).
You get a nice editor now at the bottom of the user profile:
In your themeâs
author.php
you may use the predefined action to access the data:This plugin doesn’t touch any other capability the user may have. It is bound to the ability to edit her own profile, nothing else.