Auto pick from wp_users based on the user-id that currently logged in
Dear Pods developers,
I have been using Relationship (pick) column type, and I think this is one of the great feature of Pods CMS!
I recently using it by relating this Relationship column type to the WP User in order to get the user's ID, so we will know who added the certain record for the very first time, and also who edited the certain record for the very last time.
That would be nice if you provide a new option on the Add/Edit Column for certain Pod, and then this user's ID field will become appear as "read-only and auto-save" based on the user-id that currently logged in on the add/edit form.
Any suggestion? Thanks so much.
4 Answers
Hi There,
I have added a helper to the packages page that will do this for you: http://pods.uproot.us/packages/auto-set-current-user/0.1b
You can import this package by copying and pasting the code into the package manager in your Pods plugin.
You will then have a new input helper called "auto_set_current_user" If you apply this as the input helper for your WP_User PICK column, then it will automatically set and disable the column.
What the helper does if you look at the code, is add the global $current_user so that it knows who is logged in.
The select code is the default copied from input_fields.php in the Pods plugin. The only change is that it sets "$selected" only if the id matches the current user, instead of if it is the active value.
Eris
Hi ErisDS,
Thanks so much for this great package. I have tried it, and it worked like a charm. Wonderful and good job!
You're most welcome, I'm glad it worked :)
Great job ErisDS!


