Jump to content

Category page create new listing url


Equity

Recommended Posts

Hello,

I have a custom filter to prevent users from submitting regular listings until they have created a user profile. There are two profile listing types in two different profile categories.

 <?php
defined('MVC_FRAMEWORK') or die;

//Filter - restrict all listing submissions until profile has been submitted and published
Clickfwd\Hook\Filter::add('after_filter_output_listings_create', function($output, $params)
{

    $auth = S2Object::make('auth');
    
    $app = JFactory::getApplication();
    
    $active = $app->getMenu()->getActive()->id;

	if (!$auth->admin && $auth->connected && ! UserprofilesProfileComponent::hasProfile() && ! in_array($active, array(150,142)))

	{
		ob_start();
		?>
		<p>To access this feature you must first create a public profile ...</p>
		<p><a class="jrButton jrBlue" href="https://mydomain.com/my-account/create-profile" >Create profile now</a></p>

		<?php
		return ob_get_clean();
	}
    
	return $output;
    
},$priority = 10);

This filter will stop all submissions including userprofiles. The array in the code above excludes the menu item id's to the profile listing types create page so users can submit their profile. This works as it should when using the custom menu items.

The issue is, the profile category page create new listing button uses the alias /category/new which is different than any of the menu items in the array.

When using the create new listing button on profile category page the user is still blocked from submitting their profile and redirected to the filter ob_start message because they don't have a profile.

How can I create a menu item for the profile category page create new listing buttons to include in the array or change the category submit button url to the same alias as the menu item userprofiles listing type of that category?

Thank you,

DanielH

Link to comment
×
×
  • Create New...