When a logged out visitor opens the Add Listing page, GeoDirectory shows the message “You must login to post.” with Login and Register buttons under it. It does not redirect them on its own. You can keep that message and make it clearer, or add a small snippet that sends them straight to the login page and back to the form once they are signed in.
Show login and register buttons on the Add Listing page
The GD > Add Listing block, widget and shortcode has a setting called “Show the login and register links if required”. It is on by default, and you can change the message with the Login Message setting. In shortcode form:
[gd_add_listing show_login='1' login_msg='Please log in or create a free account to add your business.']
The Login button links to wp_login_url() with the Add Listing page as the return address. With UsersWP active, that link goes to your UsersWP login page and carries a redirect_to parameter, so after logging in the user lands back on Add Listing.
Redirect logged out users automatically
If you would rather skip the message, add this snippet with the Code Snippets plugin or your child theme’s functions.php. It only runs on the page set as the Add Listing page (or any page containing the [gd_add_listing] shortcode) and does nothing if you allow posting without logging in.
add_action( 'template_redirect', function() {
if ( is_user_logged_in() || ! function_exists( 'geodir_is_page' ) ) {
return;
}
// Leave it alone if guests are allowed to post.
if ( geodir_get_option( 'post_logged_out' ) ) {
return;
}
if ( geodir_is_page( 'add-listing' ) ) {
wp_safe_redirect( wp_login_url( geodir_curPageURL() ) );
exit;
}
} );
Because the snippet passes the current URL, a link such as /add-listing/?listing_type=gd_place brings the user back to the same post type after login.
New users who register first
Registration is a separate step. UsersWP sends new users to the page set in its register redirect setting, unless the register request includes a redirect_to value. If most of your visitors need to register before they post, set the register redirect to your Add Listing page.
If you prefer to only change the menu, a plugin that shows menu items by login status lets you give logged out users a link to /login/?redirect_to=https://example.com/add-listing/ and logged in users a link to the Add Listing page itself. Replace the paths with your own login and Add Listing pages.