Skip Navigation

[Resolved] Edit User Field for Author of Current Post

This support ticket is created 5 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.

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)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Sean 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1228200

I have a bunch of post types with varying relationships. None of that really matters for this question.

I have created a user form to edit a specific field for a user ("special notes" in this case). But I can't find a method by which I can create a form so that I can edit the AUTHOR of a specific post. Right now the options look to be either the currently logged in user, or naming a specific user. I want it to be the author of whatever post I'm showing in the loop. Is that possible?

#1228205

There's no way to do that from the GUI, but the shortcode generated by the GUI looks like this:

[cred_user_form form='edit-user-1' user='2']

The '2' represents the ID of the User you want to edit. So in theory you could replace that with another shortcode that returns the User ID of the current post's author. For example, the wpv-post-author shortcode:

[wpv-post-author format="meta" meta="ID"]
#1229624
dual-forms.png

Thank you, that worked.
I'd like to have it be on a different page, but it doesn't work the same way as a cred_link_form does. Right now it's all on the same page as existing form fields and it looks awkward to have two submit buttons. Taking them to a different page while maintaining the link to the current post would be ideal. Thoughts?

#1229629

You could create the link in your loop and pass the User ID in the link as a URL parameter. Then use the wpv-search-term shortcode to access that parameter on page 2, in the Form shortcode.

<!-- on <em><u>hidden link</u></em> -->
[cred_user_form form='edit-user-1' user='[wpv-search-term param="yourUrlParam"]']
#1229676
Screen Shot 2019-04-11 at 3.46.27 PM.png

Awesome.
I had success with something like:

<a href="<em><u>hidden link</u></em> format="meta" meta="ID"]">Add/Edit User Notes</a>

The only thing it was missing was showing WHICH user it was editing. Sometimes you click and forget which user you were on. Well, the custom field isn't set to respond to the url parameter. I tried putting it in a user view, but I think I may have something wrong because it only sometimes works.

What am I missing?

#1230584

You can pass the ID of an arbitrary User into the Types usermeta field shortcode like this:

[types usermeta='pref-name' user_id='[wpv-search-term param="whichuser"]'][/types]

More examples here: https://toolset.com/documentation/customizing-sites-using-php/functions

#1234706

That seems to do the trick. Thanks 🙂