- This topic has 8 replies, 2 voices, and was last updated 3 years, 7 months ago by
Steve.
-
AuthorPosts
-
-
June 18, 2018 at 4:52 pm #9056
naurojrMemberHi PK Forum,
I’ve been trying to get a front-end form working for non-logged users but for some reason, it doesn’t.
I’ve stripped the form to the bare minimum and it still, it only saves data when the user is logged.Here is the code I’m using. Any suggestions?
<?php
/*
Title: Add New Client
Method: post
Message: Client Saved
Logged in: false
*/// Where to save this form
piklist(‘field’, array(
‘type’ => ‘hidden’
,’scope’ => ‘post’
,’field’ => ‘post_type’
,’value’ => ‘client’
));piklist(‘field’, array(
‘type’ => ‘text’
,’scope’=>’post’
,’columns’ => 12
,’field’ => ‘post_title’
,’label’ => ‘Name’
,’description’ => “”
,’attributes’ => array(
‘class’ => ‘regular-text’
,’placeholder’ => ‘Enter client\’s Full Name.’
)
,’required’ => true
));piklist(‘field’, array(
‘type’ => ‘hidden’
,’scope’ => ‘post’
,’field’ => ‘post_status’
,’value’ => ‘publish’
));piklist(‘field’, array(
‘type’ => ‘submit’
,’field’ => ‘submit’
,’value’ => ‘Submit’
));
?> -
June 18, 2018 at 9:52 pm #9057
-
June 19, 2018 at 9:02 am #9058
naurojrMemberThank you Steve. Do you have any estimate on when that would be working? No pressure, just want to plan accordingly.
By the way, great work on Piklist improvements.
Best regards,
Nauro Rezende Jr.
-
June 19, 2018 at 9:14 am #9059
SteveKeymasterSo happy you like the improvements!
A quick way for you to fix it:
1) Create a custom user role with no capabilities. You can do it with code, or a plugin like “Members”
2) Then assign that role to each field.For example, if you create a role called “submitter”, then your fields will look like this:
piklist(‘field’, array( 'type' => 'hidden' ,'scope' => 'post' ,'field' => 'post_type' ,'value' => 'client' ,'role' => 'submitter' ));You need to add
'role' => 'submitter'to each field, except submit. -
June 19, 2018 at 2:05 pm #9060
SteveKeymasterI put in a Pull Request for this. Would appreciate if you could test my code:
https://github.com/piklist/piklist/pull/104/filesIt should work with the code you posted above. No need to add the
roleparameter. -
June 19, 2018 at 5:22 pm #9061
naurojrMemberIt works like a charm 🙂 I will make some additional tests and let you know if something breaks, but it looks like everything will work. Thank you very much for your help.
-
June 20, 2018 at 11:03 am #9065
-
June 20, 2018 at 1:51 pm #9066
naurojrMemberHi Steve,
Regarding saving the data, everything is work perfectly. I only found a minor bug.
When you have required fields, that are not filled and hit submit.
The page shows the success message and the error messages all at the same time.See screenshot attached.
Attachments:
You must be logged in to view attached files. -
June 20, 2018 at 3:13 pm #9068
SteveKeymasterThanks! We’ll look into this.
-
-
AuthorPosts
- You must be logged in to reply to this topic.