Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Hi ( again ;) ),

I have this form, with which I want to reset some variables for every registered user. It does what it is supposed to do, but instead of getting redirected a "Cheating?!" message is getting displayed. What am I doing wrong?

Code: Select all
<cms:set submit_success="<cms:get_flash 'submit_success' />" />
<cms:if submit_success >
   <h4>All users now have to verify their privacy settings.</h4>
</cms:if>
   
<cms:form
   method='post'
   anchor='0'
>

   <cms:if k_success >
   
      <cms:pages masterpage='users/index.php'>
      <cms:db_persist
         _masterpage=k_template_name
         _mode='edit'
         _page_id=k_page_id
         _separator='|'
         
         user_verify_privacy='1'
      />
      </cms:pages>
   
      <cms:set_flash name='submit_success' value='0' />
      <cms:redirect k_page_link />
   </cms:if>
   
   <cms:if k_error >
      <h4>Error</h4>
      <cms:each k_error >
         <br><cms:show item />
      </cms:each>
   </cms:if>
   
<cms:input type="submit" value="Submit" name="submit"/>

</cms:form>
Most probably your code is trying to modify admin/super-admin accounts.
As a security measure, DBFs can only work with accounts lesser than the two mentioned.
Try excluding them from the cms:pages loop (e.g. using page_name='NOT .., ..' parameter>.

Hope this helps.
It did :). Thank you very much again!
Im having the same problem but my code is a bit different! Maybe you can see why i get this message 'Cheating!?'

Code: Select all
<cms:form
masterpage='users/nytt-fraver.php'
mode='create'
enctype='multipart/form-data'
method='post'
anchor='0'
>

<cms:if k_success >

<cms:db_persist_form
_invalidate_cache='0'
_auto_title='1'
/>

<cms:set_flash name='submit_success' value='1' />
<cms:redirect k_page_link />

</cms:if>

<cms:if k_error >
<div class="error">

<cms:each k_error >
<cms:show item /></cms:each>

</cms:if>

<cms:input name="fullname" type="bound" class="form-control" />

<cms:input name="type" type="bound" class="flat" />

<cms:input name="lenght" type="bound" />

<cms:input name="cause" type="bound" class="form-control" />

<cms:if "<cms:not submit_success />" >
<button type="submit" class="btn btn-primary">Legg til ny</button>
</cms:if>

</cms:form>
@kimheggen, have you, by any chance, set the access_level for the template (users/nytt-fraver.php)? e.g. as follows -
<cms:template clonable='1' access_level='4'>
Yes

<cms:template title='Add New Absence Mobile' clonable='1' access_level='1' />
That would explain the problem.

An unauthenticated visitor of the site has an access_level of '0' (http://docs.couchcms.com/concepts/users.html).

If such a visitor uses the form to create a page with an access level higher than what she herself possesses, Couch will not allow that.

To allow unauthenticated visitors to create pages from the front-end, please just remove the 'access_level' parameter from cms:template. Don't forget to visit the changed template as super-admin for the change to be registered.
Thanks. Yes i had access level 7 on one page. change it and now it works perfect.
I am using extended users and have page_hit counter as text editable in account template /users/index.php
I have "Cheating?!" every time anonymous visits a userpage /users/trendoman.html.

There is no access control and I can persist page_hits to any other template, but not extended. I realize, that anonymous visitor (0) is trying to save data to registered user (2/4).
But creating another template to store page_hits per each user probably requires manual duplicating usernames and I try to avoid it.

Here is the solution to the issue. I will create a new template, which will be called stats.php (Statistics). It will be used to hold Votes and PageHits for each user with a clonable page per user. I will also autocreate clonable pages to make automatic creation for each user. This simple template will have no access control and its pages are not secured, so no problem saving data there.
download (15).png
download (15).png (5.36 KiB) Viewed 2802 times
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
9 posts Page 1 of 1