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?
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"]
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?
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"]']
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?
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
That seems to do the trick. Thanks 🙂