I have several forms that need to have select boxes to choose a user. I am in no way seeing how to put my users into CRED, filter them, or anything.
Example:
I have a request form that contains many parent/child relationships and in general works great... However I want to add an Owner field.
What I did: Added a user meta field. So each user can checkmark that they are a possible "Request Owner". Also I have created a custom group for these people.
When I use CRED I pull up the user meta field (Request Owner). But that simply gives the checkbox that I have on each person's profile page. I would like that there be a select box that is populated by anyone that has checked that they are a Request Owner...
Do you have any examples of how to set up a dashboard scenario? Sorry if this seems basic but can't find out how to assign this user meta field to a post type.
Also to add to this if you have any documentation at all about using the user information in forms I would love to see it. I have other scenarios where I need to for instance have a "co-owner/author" to a post type that allows a multiple select.
You can try create a view list all users who are a possible "Request Owner", and output it with JSON string,
and add a generic select field into your CRED form with the values of above view,
More help:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred-generic-field
and check the solution in another thread:
https://toolset.com/forums/topic/cred-select-for-post-fields/
Can you give me an example of a sites user list in a select box filtered with administrator privileges in JSON?
I am terribly disappointed that this isn't part of the core offering. I was assuming when I saw the User Fields in Types that I could use said fields to dynamically filter content to the end user... well I can but only in the post relationship. Anyways I would ask that your dev team adds this to their roadmap.
(Also this forum needs a rework too. If I open up this window and respond a couple hours later, it tells me that I am not logged in, after I hit submit... and everything I wrote is toast. Maybe don't take user to new page based on log in query before submit is executed? )
Ok I created a view that filters what I need and display the output to the JSON format that you gave an example of.
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
{"value":"[wpv-user field="ID"]","label":"[wpv-user field="display_name"]"},
</wpv-loop>
{"value":"1","label":"No Owner"}
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]<strong>No items found</strong>[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
On the view page it displays this:
{"value":"2","label":"Second User"}, {"value":"1","label":"Dan Moore"}, {"value":"1","label":"No Owner"}
In cred I create a field and point to the View shortcode:
[cred_generic_field field="Owner" type="select" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":[],
"options": [ [wpv-view name="Learning Users"] ]
}
[/cred_generic_field]
Then I get nothing at all. I have tried to include the whole options statement with brackets in the view and so forth and it is blank. But if I just copy my view output and put it into the cred field... it works fine.
So the post you gave me before was never "fixed" and now I am in the exact same spot as previous user.
#1 The View shortcode isn't outputting in the CRED field.
#2 I don't see a way to get rid of the trailing comma in a view other than create a dummy value outside the loop.
#3 This should be easier. I don't understand why I can't pull in users and users' meta in CRED.
Also if you have any suggestion of a plugin or another product that works better to pull user info over I will use anything. I can't imagine jumping through these hoops 50 more times.
OK I have looked through all documentation that I could find regarding the CRED generic fields. All I can find is a half page of here is the picture of the gui. I have tried other examples of using the views shortcode. It seems that the view is pulling inside the form but not in a option output. Whatever is going on between view output and the input needed for options, some character(s) are not valid and it is killing everything.
I have tried the simplest things in the world and don't understand how this function could possibly work. Please please need help with this and documentation.
I assume you can create the view which filter with the all users who are a possible "Request Owner"
Here is a test site for you:
hidden link
user/pass: xgren/111111
1) create a view filter with the all users who are a possible "Request Owner", in section "Layout HTML/CSS/JS ", use below codes:
hidden link
[wpv-layout-start]
[wpv-items-found]
<wpv-loop> {"value":"[wpv-user field="ID"]","label":"[wpv-user field="display_name"]"}, </wpv-loop>
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]<strong>No items found</strong>[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
2) in the CRED form, insert the generic field as below:
[cred_generic_field field="Owner" type="select" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":[],
"options": [[wpv-view name="Pulling user information into CRED form"] {"value":"1","label":"No Owner"}]
}
[/cred_generic_field]
hidden link
Please check if it is what you need:
hidden link
I tested this out on my site and I really don't understand what is going on. My View initially had a couple filters (but the View displayed just fine and the exact same way as yours). My CRED had a lot of other fields which you see above and also notifications and uses a custom type not Post. It still doesn't work and the field throws a formatting error.
I did a test just like yours on my site and this works fine. But if I copy the code over so that the formatting is the same into my CRED form it still throws an error for the field. I will add one thing at a time and say what is causing it to break. I have a feeling there might be something messed up with the CRED form I am doing and I am not seeing it in the editor.
Plus is there a way to get rid of the last comma in the loop so that I don't have to have a "No Owner" field. There is no way this will work for everything that I am doing.
Could you duplicate same problem in a test site, and fill below private detail box with the login details, also point out the problem page URL and CRED form URL, I need a live website to debug this problem, thanks
I can't give access to my site because it is unreachable behind firewalls. There is something wrong with the original View I created. I duplicated all of the View properties and filters and the duplicates work fine - I just copied and pasted the text boxes so they are exact. I have no clue why I can see the View displayed right above the form but the view data won't go in the form - I will just delete this view and act like it never happened.
However I will note that the "sort by" has issues on the Views. I have our company IDs for our "user login". When I leave a View to be sorted by user login, I get some really flaky results and not the whole user base - tried this multiple times. However when I change the filter to nicename or display name it works fine.
So the only thing left is the No Owner comment. How do I get rid of that? I would rather not have a default choice on every user dropdown that is extra.
thanks
OK and I think I figured out what the issue was with the faulty View. I had the same view name as a Group Name for User Fields. It would be nice if we just get an error message telling us not to use the names. I just tried using a View name that was the same as a slug name for a Type and it jacked up the filters I could use/not use... Now that I know this I can keep it in mind when naming but no errors and random issues.
Good to know it is fixed, is the problem resolved? please let me know if you need more assistance, thanks
I would like a way to get rid of
{"value":"1","label":"No Owner"}
Since everything should have an Owner and I am allowing them something else.
Also along the same lines when you have select boxes that use parent fields there is a default "No Parent". I know that you can change the wording for this but I would also like to hide this.
thanks
you can try modify your view like this:
hidden link
...
<wpv-loop> [wpv-item index=1]{"value":"[wpv-user field="ID"]","label":"[wpv-user field="display_name"]"} [wpv-item index="other"],{"value":"[wpv-user field="ID"]","label":"[wpv-user field="display_name"]"}</wpv-loop>
...
More help:
wpv-item
index:
number of the post | other | pad | pad-last
index=1 will target the first record output by the loop. index=other will target all records that do not have a specific index set. index=pad will be executed if there are no records left to output, but the number of records is not a multiple of the loop wrap value. index=pad-last will be executed for the last item in the loop if are no records left to output, but the number of r