0

CiviCRM 5.48.0, WordPress 5.9.3, PHP 7.4.29.

I'm trying to create a link based on content in the user's profile (custom field for VIN, link is to do a recall search on that VIN, but the possibilities here are pretty much endless). My first idea was to just insert some PHP snippet using the Insert PHP Code snippet WordPress plugin ... but any PHP function to get CiviCRM user context has eluded me so far. Doesn't seem to be part of what wp_get_current_user() returns either.

Then I had an idea to maybe just have a simple transform on the field... but that's eluded me as well.

Thought I found a possible way with the wp-civicrm-ux extension but that killed the site when I tried to install it (didn't spend any time figuring out why, wasn't sure if it would even solve my problem).

So, is there any way to access CiviCRM field content within WordPress to do custom manipulation of that data?

Thanks.

Michael

1 Answer 1

1

You can use CiviCRM Profile Sync for this if you have ACF installed - or better still ACF Pro for greater compatibility and more Field Types.

It takes a bit of setting up, but what happens is that you sync a CiviCRM Contact Type with a WordPress Custom Post Type (or User) and then sync CiviCRM Custom Fields with ACF Custom Fields attached to the Post Type (or User). These can then be rendered in your theme using the standard ACF functions.

More info can be found in the documentation.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.