Skip Navigation

[Resolved] Duplicating post field data to a user field

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

Our next available supporter will start replying to tickets in about 3.90 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Noman 7 years ago.

Assisted by: Noman.

Author
Posts
#584801

Is this possible -

Author of custom post adds data to a custom field. On save that data is copied automatically to a custom user field in that author's user profile ?

Many thanks

Chris

#584835

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Chris,

Thank you for contacting Toolset support. Just to make sure we are on the same page, you are trying to do the following:

1. You would like to add 2 custom fields with same name - one in Custom post and another with same in the User profile field?
2. Will it be a normal custom field or repeating field?

This is possible using some custom code, to fill user profile field we need to have following data:
1) Custom field Value
2) User ID

- You can use save_post hook for getting custom post field value:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

- You can get current logged in user id by using following function:
https://developer.wordpress.org/reference/functions/get_current_user_id/

- Then we can update user profile field by using following function:
https://codex.wordpress.org/Function_Reference/update_user_meta

I hope it helps, Thank you

#584933

Yes, you are correct and the field field is normal (select) field and does not repeat.

I'll look at the links, though I may need to get some help writing the custom code.

Many thanks.

#585131

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

okay please try it out and let us know how it goes. We can provide basic help on the custom code hints and tips.

Alternatively, for more advance help we recommend to contact Toolset recommended service providers to further discuss the custom approach. We have some recommended list of service providers here if you would like to take a look: https://toolset.com/consultant/

Thank you