Skip Navigation

[Résolu] How to pass ID of the person performing the edit

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I would like to capture information about the User who submitted a CRED edit post form so I can moderate submissions efficiently from wp-admin.

Solution: Use a generic field in the form to capture the current User's ID, then use the CRED API to do something with that information.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/

This support ticket is created Il y a 6 années et 7 mois. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 23 réponses, a 3 voix.

Dernière mise à jour par johnR-22 Il y a 6 années et 6 mois.

Assisté par: Christian Cox.

Auteur
Publications
#902076

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Jamaica (GMT-05:00)

Hi John,

This actually goes into your CRED form.

So when you get the information of the person making the edit. Is it that you want them to be a contributor automatically or is it that you will go in and manually set the role?

Please let me know.
Thanks,
Shane

#902090

Thanks Shane.

I just want to know who edited the content, because if its spam, Ill ban them or delete their account.

I got it working using this, but again it only gives me their name.

<div class="hidden">
[cred_field field='revision-author' post='vehicle' value='[wpv-current-user]' urlparam='']
</div>

#902094

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Jamaica (GMT-05:00)

Hi John,

So if the code below works.

[cred_field field='revision-author' post='vehicle' value='[wpv-current-user]' urlparam='']

Then to get the author's ID you need to use this one.

[cred_field field='revision-author' post='vehicle' value='[wpv-current-user info='id']" urlparam='']

Please let me know if this helps.
Thanks,
Shane

#902268

Thanks Shane,
Ive got that working. Im pushing both name and ID into separate fields, although that kind of seems odd. Im pretty sure there's probably a much better way of doing this.

Ideally Id like to see a photo of the person, their name and perhaps their profile URL (or be able to click on the profile photo which takes me to their profile page) so that I can quickly glance at it and know who made the change.

I just need a way to quickly identify who made the change, so that I can process it without having to muck around - incase I have hundreds of revisions to go through.

#902519

Ok, I now have the users name and ID passed via the form into the back end.

This means when moderating post edits, I have to look at the name, then look at the ID, then perform a search within users and match that up and then figure out what to do from there.

This probably wouldn't be an issue, but it's certainly going to become problematic, surely, if I end up with thousands of contributors.

I do apologise for the ongoing questions.

I'm just trying figure out how best to handle revisions by contributors in an efficient manner in the back end.

Again I just need to know who has made the revision (quickly) so I can either -

a) approve their submission, or
b) ban them because they've posted spam

Surely someone else has asked this question before?

#902528

Hi, Shane is on holiday today and will return tomorrow to follow up on this ticket.

#902530

Thanks Christian.

For now Im using the following shortcode information to capture the users name and email.

<div class="hidden">
[cred_field field='revision-author' post='vehicle' value='[wpv-current-user]' urlparam='']
[cred_field field='revision-email' post='vehicle' value='[wpv-current-user info="email"]' urlparam='']
</div>

This is relatively straight forward. I'll just keep a secondary tab open in the browser and if anyone submits nonsense Ill search under users by email address and drop the ban hammer.

Unless you have a better suggestion Christian?

#902576

Maybe use a WYSIWYG custom field to store a full link to the author's profile. For example, if you insert this code in a WYSIWYG field and show the "Visual" tab in wp-admin, you will be able to click the link to visit that URL directly from the post editor screen:

<a href="<em><u>lien caché</u></em>">someusername archive</a><br />
 or
<a href="<em><u>lien caché</u></em>">User ID 12345</a>

It might save you some time during moderation.

So your CRED field might look something like this:

[cred_field field='revision-author' post='vehicle' value='<a href="<em><u>lien caché</u></em> info='id']">View User Profile</a>' urlparam='' output='bootstrap']

Only the site Admins will see this information in wp-admin, it won't be visible on the front-end of your site anywhere.

#902772

Thanks Christian.

I think for now Ill just capture their name and email and keep the "users" tab open and look them up that way. Its not ideal but should work.