Each GeoDirectory post type has a Limit Posts Per User setting. Set it to 1 and every user can add one listing of that type, or use any other number.
Set a limit for a post type
- Go to Places > Settings > General, or the Settings menu of the post type you want to limit.
- Click Show Advanced if you do not see all the settings.
- Enter a number in Limit Posts Per User. Leave it blank or enter 0 for no limit. Enter -1 to stop users adding listings of this type at all.
- Save.
When a user reaches the limit, the add listing page shows a message instead of the form. The count covers the user’s listings in that post type, not only the published ones. Administrators are never limited.
The limit applies to logged in users. If you allow guests to add listings, they are not counted.
Different limits for different user roles
To give each role its own limit, use the geodir_cpt_posts_limit filter. This example allows subscribers one place and authors ten, and leaves everyone else on the post type setting. Change the post type and the roles to suit your site:
add_filter( 'geodir_cpt_posts_limit', 'my_listing_limit_by_role', 10, 2 );
function my_listing_limit_by_role( $limit, $args ) {
if ( empty( $args['post_author'] ) || $args['post_type'] !== 'gd_place' ) {
return $limit;
}
$user = get_userdata( (int) $args['post_author'] );
if ( ! $user ) {
return $limit;
}
$role_limits = array(
'subscriber' => 1,
'author' => 10,
);
foreach ( $role_limits as $role => $role_limit ) {
if ( in_array( $role, (array) $user->roles, true ) ) {
return $role_limit;
}
}
return $limit;
}
Add it with the Code Snippets plugin or your child theme’s functions.php.
The limit is per account, so someone who really wants more listings can still register a second account.