How to redirect to plan purchase after listing submission

Hi! I’m building a Rhode Island beauty and wellness classifieds website using HivePress Memberships and WooCommerce.

We have two paid listing plans: $19.99 for spaces and $9.99 for jobs, each lasting 30 days.

Currently, customers must purchase a membership plan before entering their listing details.

We’d prefer customers to complete their listing first, review it, and then pay before publication.

Is there a supported way to accomplish this using Memberships, without switching to the deprecated Paid Listings extension?

We also want listings to publish automatically after successful payment, without manual approval.

Thank you!

Thanks for your message — our team will reply shortly.

In the meantime, you can also get instant help from our AI Assistant, familiar with all the docs and solutions we’ve shared over the years.

Hi,

There’s no such option yet, but we plan to add it in future updates. As a temporary solution, please try the code snippet below. You can add it with the Code Snippets plugin:

// Require a membership after adding listing details, not before.
add_filter(
	'hivepress/v1/routes',
	function( $routes ) {
		if ( isset( $routes['listing_submit_details_page']['redirect']['membership'], $routes['listing_submit_complete_page']['redirect'] ) ) {
			$redirect = $routes['listing_submit_complete_page']['redirect'];

			if ( is_callable( $redirect ) ) {
				$redirect = [
					[
						'callback' => $redirect,
						'_order'   => 5,
					],
				];
			}

			$redirect['membership'] = array_merge( $routes['listing_submit_details_page']['redirect']['membership'], [ '_order' => 1 ] );

			$routes['listing_submit_complete_page']['redirect'] = $redirect;

			unset( $routes['listing_submit_details_page']['redirect']['membership'] );
		}

		return $routes;
	},
	1000
);

// Remember the page to return to after buying a membership.
add_action(
	'template_redirect',
	function() {
		if ( function_exists( 'WC' ) && WC()->session && hivepress()->router->get_current_route_name() === 'membership_plan_select_page' ) {
			WC()->session->set( 'hp_membership_redirect', hivepress()->router->get_redirect_url() );
		}
	}
);

// Return to that page after a successful membership order.
add_action(
	'template_redirect',
	function() {
		if ( ! function_exists( 'is_wc_endpoint_url' ) || ! is_wc_endpoint_url( 'order-received' ) || ! WC()->session ) {
			return;
		}

		$redirect_url = WC()->session->get( 'hp_membership_redirect' );
		$order        = wc_get_order( get_query_var( 'order-received' ) );

		if ( ! $redirect_url || ! $order || ! $order->is_paid() ) {
			return;
		}

		$product_ids = hivepress()->woocommerce->get_order_product_ids( $order );

		if ( ! $product_ids || ! \HivePress\Models\Membership_Plan::query()->filter( [ 'product__in' => $product_ids ] )->get_count() ) {
			return;
		}

		WC()->session->set( 'hp_membership_redirect', null );

		wp_safe_redirect( $redirect_url );

		exit;
	}
);

For automatic publishing, unfortunately the only way is to disable moderation in HivePress/Settings/Listings. But if publishing any listing on your site is paid, the paywall will still prevent spam.

Hope this helps