klox7 VIP
Total posts: 914
17 Oct 2014 15:10

Hello,

my users can add records to site but with limited options. Some field are activated by subscription.

If a user buys a subscription for subscription based fields I want them to be able to use this subscription only once for one record. They can edit this record anytime.

If a user wants to use same field on another record of his he must buy another subscription (same plan).

Is this kind of configuration possible?

Regards

Last Modified: 25 Dec 2014


pepperstreet VIP
Total posts: 3,837
11 Nov 2014 10:06

Sergey count usage have to have it's own number per every restriction. This is something we are looking into for the future.

+1 :)


klox7 VIP
Total posts: 914
13 Nov 2014 18:24

Sergey Plan 1 Show all fields

  • Usage limit 1
  • Count mode Every URL

Count mode Every URL = Count Every access?

Sergey Type settings

  • Submision restriction Plan 1, Plan 2, Plan 3
  • Count limit Yes

Isn't this restricting record for submission? If so I have restricted submission but user can still submit.


Sergey
Total posts: 13,748
14 Nov 2014 02:48

klox7

Sergey Plan 1 Show all fields

  • Usage limit 1
  • Count mode Every URL

Yes.

klox7 Isn't this restricting record for submission? If so I have restricted submission but user can still submit.

  1. You do not test as admin, don't you?
  2. Every access is selected for submission?

klox7 VIP
Total posts: 914
14 Nov 2014 08:42

Sergey You do not test as admin, don't you?

No.

restrict-type

plan-params


Konstantin
Total posts: 1,113
17 Nov 2014 07:07

klox7 If a user buys a subscription for subscription based fields I want them to be able to use this subscription only once for one record. They can edit this record anytime.

Make some fix for type setting 'Skip for Author' when user add new record.


klox7 VIP
Total posts: 914
17 Nov 2014 08:02

Konstantin Make some fix for type setting 'Skip for Author' when user add new record.

Could you please explain more?


Konstantin
Total posts: 1,113
17 Nov 2014 08:48

You can check it after next release and update this on your site. Fix with adding more than one record.


klox7 VIP
Total posts: 914
21 Nov 2014 15:37

Konstantin You can check it after next release and update this on your site. Fix with adding more than one record.

Is this fix for submission restriction or for initial question - count individual submissions with by fields restriction.


Konstantin
Total posts: 1,113
24 Nov 2014 11:43

I think for both case.


klox7 VIP
Total posts: 914
16 Dec 2014 19:53

I guess I can't count submissions with restriction by fields or I just don't know how to set it up.

So for this specific flow I made a workaround for myself. Here is how if anybody will need it but keep in mind that I have only offline payment!

The initial idea was when submitting record to show all fields in form but in record full view show all fields only if user has subscription, otherwise don't show fields that requires subscription. I wanted to limit 1 subscription to 1 record. There are several plans which includes different combination of fields. That gives user the control to "build his own recor view".

So I created additional text fields (one for each subscription) visible only for administrators. If user buys subscription I have to manually enter it in record for which he want to use this subscription. This is not the perfect solution but I'll live with it for now.

Then I added this in my custom record Cobalt template around the fields for which I need this.

if(!EmeraldApi::hasSubscription(array(1,5), null, $item->user_id, false, false) && (isset($item->fields_by_id[315]) || isset($item->fields_by_id[316]))):

where array(1,5) are plans that user needs and fields_by_id are text fields which I enter them manually.

This gives me control to assign specific subscription to specific record, something like "attach this subscription to this record".

If anybody has solution that makes more sense please enlighten me, I'm out of ideas.

Regards

EDIT: you can use just isset without !EmeraldApi::hasSubscription and configure your settings in Emerald tab in Cobalt field.


klox7 VIP
Total posts: 914
17 Dec 2014 08:15

In the upper code how to show fields if author of record has subscription?


Sergey
Total posts: 13,748
19 Dec 2014 05:22

klox7 In the upper code how to show fields if author of record has subscription?

There is a parameter in field parameters on Emerald tab. View restriction is subscription for one who see article and display restriction is for author of the record to have subscritpion.


klox7 VIP
Total posts: 914
19 Dec 2014 11:01

I am courious about something. Why does this setting in Cobalt field

display_field

prevents to display code inside if(isset($item->fields_by_id[ID])): for this field?

Isn't "View Access" parameter just for restricting field value?

I'm asking because I'm wrapping one field with another, so if 1st field is set then display 2nd field also if is set. But if the 1st has "Special" in "View Access" then second field won't display. I'm setting 1st field to "Special" because I don't want in any circumstance to show it?

EDIT: I just noticed that if I insert something in "Restriction message" then it's working fine. If I use default message or just white space then there is no result when "Who can view field value" of 1st field is "Special".

My code is simply this:

<?php
if(!empty($item->fields_by_id[315]) || !empty($item->fields_by_id[326])): //fields with "Special" who can view
?>
    <?php //telephone
    if(isset($item->fields_by_id[11])): //field with "Public" who can view
    $field = $item->fields_by_id[11]; ?>
        <div id="<?php echo 'field-rslt-'.$field->id; ?>" class="<?php echo $field->fieldclass;?>">
            <?php echo $field->result; ?>
        </div>
    <?php endif; ?>
<?php endif; ?>

Sergey
Total posts: 13,748
22 Dec 2014 05:35

klox7 Isn't "View Access" parameter just for restricting field value?

Yes. If there is no value, then there is no sence for the field to be there. If youwould enter message parameter, then fiel value would be that message and then you would have that field.

Since in universal templates we use foreach($item->fields_by_id ... to list all fields, we have to make sure that fields with empty values are not included into that array at all.


Sergey
Total posts: 13,748
25 Dec 2014 14:16

I have little filter before template gets fields all fields where $item->fields_by_id[ID]->result is empty are removed. So if you have $item->fields_by_id[ID] you will have ->result aloso. If there is no ->result there is no $item->fields_by_id[ID] either.

If you set field special and public or registered user access page $item->fields_by_id[ID]->result may be theer or not depending on your decision. And that is restriction message text. If you enter text, then ->result will have that text. If you enter white space there, there will not be either $item->fields_by_id[ID] or $item->fields_by_id[ID]->result.

Powered by Cobalt