Adding more attributes to the different packages

Hi. Could you please add different character limitations for different packages or give me a code where i can set the character limitation for a specific package. I know how to add the limitation feature but I need the if-function in the code. Anyone who can help?!

And I would also really need a feature that only allows verified users to choose free packages.

Thanks in advance!

Hi,

Sorry, there’s no simple code snippet for this, it would require a custom implementation, but we plan to add it.
Additional customization is also required to limit free packages to verified ones.

But what about this code. Isn´t this pretty similar to what I want and only needs a few changes?

Code for statisitc overview only for specific package:

add_filter(
‘hivepress/v1/menus/listing_manage/items’,
function ($items, $menu){
if ( isset( $items[‘listing_edit’] ) && hivepress()->get_version( ‘memberships’ ) ) {

		$listing = $menu->get_context( 'listing' );

		if ( hivepress()->helper->is_class_instance( $listing, '\HivePress\Models\Listing' ) && $listing->get_status() === 'publish' ) {
			if(is_user_logged_in() && $listing){
				$membership = \HivePress\Models\Membership::query()->filter(['user' => get_current_user_id()])->get_first();
		
				if(!$membership || in_array($membership->get_plan__id(), [1,2,3])){
					unset($items['listing_statistics']);
				}
			}
		}
	}

	return $items;
}, 
1000, 
2 

);

Code for character limitation

add_filter(
‘hivepress/v1/forms/listing_update’,
function( $form ) {
$form[‘fields’][‘description’][‘max_length’] = 650;

	return $form;
},
1000

);

Hi,

If I understood you correctly, please try this PHP snippet:
You need to replace the numbers 1,2,3 and 4,5,6 on your plan’s ID.

add_filter(
 'hivepress/v1/forms/listing_update',
 function( $form ) {
  if(!hivepress()->get_version('memberships')){
   return $form;
  }
  
  $membership = \HivePress\Models\Membership::query()->filter(['user' => get_current_user_id()])->get_first();
  
  if(!$membership){
   return $form;
  }
  
  if(in_array($membership->get_plan__id(), [1,2,3])){
   $form['fields']['description']['max_length'] = 650;
  }elseif(in_array($membership->get_plan__id(), [4,5,6])){
   $form['fields']['description']['max_length'] = 65;
  }
  
  return $form;
 },
 1000
);

Please note that it can require further customization.
If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

thanks andrii for the help but unfortunately this does not work…Pretty frustrated since I thought this should be an easy fix. However I appreciate the time you put into this

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.