Skip Navigation

[Resolved] displaying the user list fliter by the author who created it

This support ticket is created 6 years, 8 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 11 replies, has 2 voices.

Last updated by jackO 6 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#625597

Hi,

Thank you for assisting on the products. I got it working. It seem that my CSS accidentally hide the edting part. My bad.

i have another question.

I am working on a creating user form. I have succesfully create the add user form.
The next step will be displaying the user list fliter by the author who created it.

This is very different then product it seems. I cant find anyfliter to it.

Can you assist?

#625601

Please, can you explain step by step what you want to achieve?

A View, that lists users, cannot have a Custom Search.

Only Post Views can have a Custom Search, and you cannot search by Author in that.

#625620

Hi,

The steps are quite similar to adding product, listing and editng product.

The things i want to achieve is
1) Add staff form - A form that can add user (Successfuly done)
2) Display form list and edit. This list of user will be display based on the user who created it. There will be a delet and edit button
3) The edit form where the Creator can edit the user details

Will this be possible or is there a way to work on this?
Tqvm

#625657

I understand this, unless your second point:

) Display form list and edit. This list of user will be display based on the user who created it. There will be a delet and edit button

- you have an "Add user" form somewhere on the website
- when the visitor submits this form, a user is created
- the visitor can now log in, and in another location (a page for example) you can insert the User Edit Form.

It will edit the currently logged in user.

There is no point in creating a list of users that the users created.
There will be always just one user each user.

#625681

I understand this, unless your second point:

) Display form list and edit. This list of user will be display based on the user who created it. There will be a delet and edit button

- you have an "Add user" form somewhere on the website
Yes

- when the visitor submits this form, a user is created
yes, the role of the user created will be known as pending vendor

- the visitor can now log in, and in another location (a page for example) you can insert the User Edit Form.
User cannot create user, unless is a vendor. Once they become a vendor only can add new user

It will edit the currently logged in user.
- the new vendor created cant view or edit other user because it not creatd by him
- Only the user creator can edit the vendor that he/she is created

There is no point in creating a list of users that the users created.
There will be always just one user each user. ?? dont get this

Kindly give your thoughts

#625690

This is not possible.

CRED Creates a user when the form is submitted.
No matter how you approve that user later, there is no connection between the user who approved, and the user created.
Furthermore, CRED does not allow to create "Pending users", out of the box, it requires custom code or 3rd party plugins.

When you submit a "New user" form with CRED the user gets created the moment you submit the form.

Later, you cannot show in a view "who approved this user". There is no such connection in WordPress.

If "Vendor" where a Post, then this could be possible.
Then you can list a sequence of Vendors, created by the current user, or any other user, by post status and more.

But these are not users, those would be posts.

#625765

Hi,

Thanks for the feedback.
What about connection between creator can created user?

Do you mean that there is not connection or link that can be used to show only the user created by the creator?

If really so, can we add a custom field to link between them?

#625766

Correction

What about connection between creator and created user?

#625823

No, there is no such link in the entire WordPress Ecosystem of Plugins and Themes, that I know of.

This requires custom code and some more steps in the Process.

WordPress is built on the idea of a "blogging platform", that is why you will not find so much elaborated features around users, their registration and other "Member/User" oriented features.
Toolset just enhances WordPress, it wraps a lot of its features that are available only in PHP usually, into a WordPress Admin GUI.
So, such features are as well not added by Toolset, even if we help to manage users with CRED for example.

There is just simply no such feature at all in WordPress generally.

To help you to "track" this creator of a user, I need first to know exactly how you "approve" a user.

As I said, in CRED, this is not possible, so you must use some other Plugin.

The idea is, that when that plugin does it's actions (approve the user), you hook in a custom code, that as you say, stores the "Creator" in the "New User" as a user field.
This can then theoretically allow you to create a filter, where you list users, where their User Field "Creator" is for example equal to the currently logged in user.

But for this you will need to know exactly what makes the users "approved", and where their code hooks in, so you can then craft a custom code for the logic to be applied.

#625875

Thanks for the explanation

Basically my flow will be like this

When the user is created by the creator, their initial role is 'pending vendor'
Approve user will change user role from 'pending vendor' to 'vendor'

I already have a plugin (profile builder) and function that will do the approval.

I just only need to be able to create the user(done) and then diplay it according to the creator.
I am just stuck in displaying user created by user.

I am thinking the link can be a unique thing like creator id, perhaps email or username since it's unique.
Kindly share your thoughts again. Thanks!

#625881

Yes, that is the solution in this case.

I will explain what we can assist with:

1. Create a user field, this can be a simple single line
2. It will hold the User ID of the user that approved the current user
3. To update this field, you can either do so manually in each User's Profile in the backend, or thru a CRED Form, or with custom code.

Since you rely on a 3rd party to allow the user (Hence, to update this user), you need to hook in their code.
You need to know when a user is updated. They will have a function that does this that you maybe even can filter (this is a question to direct to those developers).

Once you have that, you can hook in with a simple update_user_meta(), where you update the above-created user field with the value (user id) you need.
https://codex.wordpress.org/Function_Reference/update_user_meta

The only special here is that the User Field created by Types will have a slug (metakey) prefixed by wpcf-

This means, when you update the user field with the code, you need to do something like this:

//you need to find out how you can get the user ID that is approving another user. Direct this question to the 3rd party developers, as this is not made with Toolset
$creator_id = '2'; 

//this is our Field where we will save the user id (creator) against the approved user
$creator_field = 'wpcf-your_slug_here';

//again here you need to know how to get the "approved user" ID, ask this question to the developers who develop this system
$approved_user = '3';

//Now we update the field with all data
update_user_meta( $approved_user, $creator_field, $creator_id);

Now, you could create a user View, list all users, and add a Query Filter for:

Select items with field:
your_field_slug is a string equal to equal to VIEW_PARAM(your_param)

Then, you can insert this view in a page by passing the user ID in the "your_param" attribute.
This would then for example display all users where the creator is of the same ID.

But as you see, our assistance here can be limited only

#628158

Hi,

I am trying the creator and created user issue as mention previously. Now, i have manage to display user according to creator.

But i am having this problem in the editing button

Kindly go to

hidden link and go to the top right icon and click on supplier.
Login in using this account innaj97 3lm1n@B@$ri

You may go to
hidden link

This is a sample page whereby i have manage to display the user list created by this user. But when i click on edit. I fail to send over the user id to link to the user form to edit the user info

This is my loop code
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<table width="100%" border="1">
<thead>
<tr>
<th>Username</th>
<th>First Name</th>
<th>Last Name</th>
<th>E-Mail</th>
<th>Action</th>
</tr>
</thead>
<tbody class="wpv-loop js-wpv-loop">
<wpv-loop>
<tr>
[wpv-post-body view_template="Loop item in Display List of Staff"]
</tr>
</wpv-loop>
</tbody>
</table>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

This is my template for this view
<td>[wpv-user field="user_login"]</td>
<td>[wpv-user field="user_firstname"]</td>
<td>[wpv-user field="user_lastname"]</td>
<td>[wpv-user field="user_email"]</td>
<td>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#edit[wpv-user field='ID']">Edit</button>
</td>
<!-- Modal -->
<div class="modal fade" id="edit[wpv-user field='ID']" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit Profile - [wpv-user field="user_login" id="[wpv-user field='ID']"]</h4>
</div>
<div class="modal-body">

[cred_user_form form="edit-staff" user="190"]

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

I manage to figure out the display but the edit dont work accordingly. kindly assist