Skip Navigation

[Resolved] validate if username is an existing valid user

This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by peterL-5 4 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#1606461

Tell us what you are trying to do?
I am using Ultimate Member plugin for user registration (there I extended user profiles and created roles that dictate access to pages and the page contents).

I would like to build a CPT in Toolset:

Project - subset of fields:
projectName
projectDescription etc

REPEATED FIELD
projectParticipant = username (this is a registered user)
projectParticipantRole

a/ When a manager registers a new project, I need to validate the entry form field "projectParticipant", "projectParticipantRole" i.e. access their user profile and store this correctly with my CPT.

Trivial example: instead of registering a non-existing "Jon Smithss" that manager obtains immediate correction e.g. "John Smith"

b/ This has two consequences that significantly help:

1/ I could display in the Toolset View CPT "My Projects" on a simple condition: if current user == project participant than display projectName

2/ I can obtain the list of valid project's participants and then send them in an API to another application to automate actions there.

Is there any documentation that you are following?
forums, your doc

Is there a similar example that we can see?
help me to find it please

What is the link to your site?
hidden link

Thank you for your help
Peter

#1606805

1. There's no inbuilt Field in Toolset to list all Users, which is what you probably would need here, so the person who fills that form can simply check several users instead of adding complex code that verifies if a eventually (manually?) added username exists.

You could, however, create a Custom Field of this kind, using some PHP code and Toolset API.

That would then avoid having to create any form of validation and failure response logic.
https://toolset.com/forums/topic/i-want-to-add-a-dropdown-with-a-list-of-all-members-with-a-certain-role/#post-328866 is an example of how you can do this.

2. Another solution is to use Post Relationships. In this case, however, each potential user is not reflected in a Field but in a Post.
This post then gets connected to a Project, where one project can have at least many users.
Note, if your users are in many projects as well then you'd need a many to many relationships and in this case, a Relationship Form. In this case, you can not apply any form of API to the form because those forms have no hooks (yet)

#1606899

My issue is resolved now. Thank you!