Home › Forums › Front-end Issues › Attach Users to Custom Post Type?
Hello, i’m trying to attach users to certain investments, once the investments have reached there target my client will manually select investors attached to the investment.
I would like to display a snippet of the investment and the updates to individual users profiles.
I’ve yet to work this one out, any ideas, articles would be greatly appreciated.
Thanks
Ricky

Hi @rickygreen
I’m not sure about your situation. Could you please share some screenshots of the issue. Also, you can query posts by custom fields. Please take a look at this page to learn more about it: http://www.advancedcustomfields.com/resources/query-posts-custom-fields/.
Thanks!
Hello James,
http://i.imgur.com/PknedLi.png – So, here you can see the user account, i have added a tab to UltimateMember plugin.
i would like to show which users are attached to which investments.http://i.imgur.com/a4QR8LC.png
This is the relevant sections of my function.php
https://gist.github.com/anonymous/21a44de272258fc30253
I did read a that article but the user bits thrown be off. Thanks

Hi @rickygreen
Multiple users field is saved in a serialized data like this: a:3:{i:0;s:3:"810";i:1;s:3:"135";i:2;s:3:"814";}.
I believe you can query the investment custom posts using this arguments code:
$userID = $current_user->ID;
$args = array(
'numberposts' => -1,
'post_type' => 'investment_cpt',
'meta_query' => array(
array(
'key' => 'investors_attach',
'value' => serialize(strval($userID)),
'compare' => 'LIKE'
),
)
);
Where ‘investment_cpt’ is the custom post type of your investment.
Please take a look at this page again to learn more about it: http://www.advancedcustomfields.com/resources/query-posts-custom-fields/.
I hope this helps.
The topic ‘Attach Users to Custom Post Type?’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.