solved How to limit the number of items a user can create?

Ken Rich
Ken Rich
@ken-rich
8 years ago
926 posts
This seems like it should be a very simple thing to accomplish, but I have made dozens of attempts and wasted many hours.

On the item_index.tpl of a module, once a profile owner has created an item in that module, I want the create button to disappear in that profile.

This is in order to limit them to the creation of one item, unless they delete it, in which case the button should reappear.

I am thinking an IF statement should work but I am doing something wrong. The button code is the same for all modules, in this case sales so:

{jrCore_item_index_buttons module="xxSales" profile_id=$_profile_id}

I am adding to it variations of code like:

 
  {if isset($_item_id.item_id) && strlen($_item.item_id) > 0}
{else}
{jrCore_item_index_buttons module="xxSales" profile_id=$_profile_id}        
      {/if}

In some variations, I try using values creates by the form like sales_editor or sales_title. I've tried empty and is null instead of isset.

In every case that didn't "break the page", the buttons were hidden on two test accounts or not hidden on the two accounts. It treats them the same but one has an item created and one doesn't.

I'm expecting the IF statement to hide the buttons on the account with the item created but not the other. That never happens in any of my coding attempts.

What am I doing wrong?


--

Ken Rich
indiegospel.net

updated by @ken-rich: 07/29/16 04:28:38AM
douglas
@douglas
8 years ago
2,790 posts
If xxSales is a module you've created by using the Aparna module, then there should be a max item field in the quota config tab.


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
Ken Rich
Ken Rich
@ken-rich
8 years ago
926 posts
Awesome - how did I overlook that?

I would prefer to hide the button but I just tested and this solution will certainly serve the purpose.

Thanks Douglas.


--

Ken Rich
indiegospel.net
douglas
@douglas
8 years ago
2,790 posts
Glad to be of help! :)


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos