Skip Navigation

[Resolved] User Field question

This support ticket is created 6 years, 5 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 5 replies, has 2 voices.

Last updated by Beda 6 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#1112431

Hello, I am adding User Fields to each of my online courses. Each new User Field currently shows up in the User Profile.

I am doing this in order to make the experience more interactive. So I may ask people to submit their favorite color, what emotion they feel today, or a compliment that they have received recently... then later in the course I will display their input in a different way, perhaps within a paragraph form.

So far this works fine. BUT before I continue, please advise on whether I may run into problems later. I am planning 10-20 Custom User Fields per course, and 50 courses, which means I'll have 500-1000 additional User Fields that will show up in the User Profile.

1. Is User Fields the right way to create these custom fields? I assume they are user fields because I want each person to only see the value that they submitted (so it's attached to the current logged-in user). But please advise if there is a better way to do this.

2. Is it okay to add this many User Fields? 500-1000 custom User Fields seems like a lot.

3. Is there a way to hide these User Fields from the User Profile? If so, can I access them elsewhere?

(My site is not live yet - it is still in development so I can't provide a link.)

#1112709

Users in WordPress are unique, and hence, if you have 10-20 User Fields per user, you can never have more than those 10-20 User Fields saved for each user in the database, since Users cannot be repeated like posts.

I am not sure how you refer Users to Courses, as there, with a relationship that you might query, this could surely affect the performance, but Users cannot be connected as such to Posts.

Eventually you followed this Tutorial and refer to that method of relating Users to Posts?
https://toolset.com/documentation/user-guides/how-to-create-custom-searches-and-relationships-for-users/

If so, this would not impact the performance more than any other Post/Post relationships and fields, whereas you are bound to WordPress' performance peaks and lows.
WordPress for example stores all posts no matter the kind in one table.
If you now query that table by posts in a taxonomy or with a field, it means you query the entire (all posts) database table and the related fields table and back the related posts.
Toolset helsp a little here as we store relationships of posts in Custom Tables, hence lifting a bit of the weight off native Posts tables in WordPress.

You can assign User Fields to users Roles, if you use Toolset Access you can control that in Toolset > Custom Fields > User Fields
On the Front end Forms of Toolset Forms you can simply exclude those inputs for example, so the users won't see them, if you need it to be avaialble only under certain circumstances.

However to better assist in detail I woudl need to know if you refer to fields in "real" WordPress users, or fields for posts, that mimick WordPress users in a Post Type.

#1112725

Thanks for the reply. My main question is: am I structuring this the right way by using "User Fields" in the first place, versus some other type of custom field? Your last sentence: "fields for posts, that mimick WordPress users in a Post Type" makes me wonder if there is a better approach, but I would need more help in understanding how to implement it.

Here is more info:

I'm using a custom post type called a "Lesson" by the LearnDash plug-in. (This seems to work equally well as if I were embedding a Toolset form inside a regular post, so let's assume there are no compatibility issues.)

I have a group of posts/lessons that are organized into a course that a user is registered for. This user has access to this course (group of posts) controlled by a membership plug-in called MemberPress. So perhaps that is the post-user relationship you are referring to above?

EXAMPLE: Let's say there are 4 lessons (posts) in my course (group of posts attached to a membership subscription). Each current logged-in user enters in their responses to: a favorite color in Post/Lesson #1, their most desired personality trait and their least desired personality trait in Post/Lesson #2, and perhaps an emotion they are experiencing today in Post/Lesson #3. Then on Post/Lesson #4, they see their own field values embedded within a paragraph. So the Post/Lesson #4 content would be a paragraph which embeds the field shortcodes in it, but each user would see a different version of the paragraph (including their own field values that they input when visiting earlier posts/lessons).

So one question is: am I using the best approach by thinking of these fields as usermeta fields? I am only doing this because I don't understand any other way... but in the article you referenced it looks like they created a custom post type which housed additional fields about the users, then pulled those values out in the form of an individual profile or a list of multiple users. I don't know how this would work in the context I am using, but perhaps I just need more information.

I am hoping I don't need to use the Access plug-in, as I attempted that before and there is a conflict with my WordPress PHP version (SiteGround host). A previous support ticket concluded that I didn't need to use the Access plug-in (since I can restrict what the user sees by clicking the "current logged-in user" option), so I'm hoping that is correct.

In the few trials I have conducted, my use of just Toolset Types, Forms, and Views seems to give me the results I seek: e.g., for the custom user field called "Favorite Color" - Mary enters "blue" and John enters "green." For most desired personality trait, Mary enters "generous" and John enters "intelligent." Then when each of these logged-in users goes to Post/Lesson #4, Mary sees the sentence: "You encountered an alien who had blue eyes and seemed generous" and John sees: "You encountered an alien who had green eyes and seemed intelligent." This all works great, and I have found no other tool that does this!!!

But when I started to count up how many user fields I'd need... 500-1000 total after I'm done with my 50 courses... I got concerned. Is this too many? Is usermeta the right way to store this info? Or do you think it would be better to do what you say in your last sentence about mimicking wordpress users? If so... I would love more information on how to set this up!!

Thank you!!

#1112776

p.s. my users are subscribers, not authors.

#1113444

Ok, I understand better now.

1. If you have information to add to WordPress Users, then you need to use User Fields.
2. If you have Posts, you need to use Post Fields.

My reference to mimicking users to posts as outlined here is only if you want to have a Custom Search on the Front End for WordPress users, something that is not possible.
In those cases, you would follow the above DOC and create Posts that mimic the users.
https://toolset.com/documentation/user-guides/how-to-create-custom-searches-and-relationships-for-users/

I don't think you need it.

About MemberPress or LearnDash - I am not familiar with them anymore, but I have played with LearnDash and Toolset in the past and concluded that:
- you can use both software on the same install, but leave each do "it's thing" (Do not add, control, manipulate elements of Plugin A with Plugin B)
- Plugins like LearnDash or Sensei, etc., bring a lot of their controls which Toolset brings as well, which will end in conflicts or limitations if you start controlling one with another, or add data from one to another.
(Access, Post Types, Taxonomies (sometimes masked as "permissions"), forms, users, user data, user permissions, etc.).

I do understand the process that LearnDash and MemberPress provide and you describe, the thing is, those answers given by the users, should probably not be added or controlled by Toolset.
Instead, you should use LearnDash's features only to control and manipulate all it's things, like courses and permissions and data.

Even if those Fields (Answers of the "user) would be created by Toolset, I am not sure where LearnDash stores that data.
Sometimes plugins do exactly what we suggest in the above-linked document (Mimic users to posts)
So you would then need to add Posts fields if you want to enrich those data sets.

You could find out from the LearnDash Support exactly where they store the data you want to play with.
Then, depending on whether that is User Data or Post Data, you can easily A) Add fields (Either user or Post fields) and B) they will then appear where you add/edit that data)
There is one caveat here if the Plugin stores User data but shows the data to edit as Post Data in the backend, or even creates a "fake" user profile edit page, you may not see the Toolset Fields on those edit screens
As said, those plugins are quite powerful, they add a lot to the blogging software WordPress, and sometimes you may not be able to control with other plugins what they do or add.

I am not sure what you refer to by "since I can restrict what the user sees by clicking the "current logged-in user" option".
The toolset has no such option, and I would not suggest controlling LearnDash things with Toolset Access, it is generally not recommended:
https://toolset.com/home/compatibility-toolset-plugins-themes/ > Access – Control What Users Can Do

Concluding, you can use both software parallel on the same system, but try not to mix them.

#1113553

changing state