Support

Account

Forum Replies Created

  • I think this might be a bug with ACF Pro – I ran into the same issue. Relationship fields don’t appear to be saving correctly when the fields are attached to the User object.

    An ACF relationship field on a Post saves as:
    a:1:{i:0;s:3:”777″;}

    While the same relationship field, made as a fresh field group, on a User saves as:
    a:1:{i:0;s:3:777;}

    I just spent 4 hours trying to figure out what was wrong with my meta query until I finally checked the database on a whim, and realized that the value isn’t saved the standard way to the User object (user_meta table).

    Is there a reason why it saves in a different format to the User format than it does to the Post format?

  • Hi Beee, sorry for the late response. I was facing a limited deadline and project budget, so instead I opted with the client to train employees not to click the link. Not a real solution unfortunately :/

  • Thanks for the quick reply John!

    Our sites do already have the admin menu hidden from clients (including the Admin role), however that doesn’t seem to prevent this particular issue.

    I’ll need to look into the ACF capability settings – I wasn’t aware of that feature. Thank you for the link!

  • Jeremy was on the right track for the simplest solution, but had a couple typos.

    FIXED code to get user ID:

    $select_staff = get_sub_field('select_staff');
    $select_staff_id = $select_staff['ID'];

    The User Relation field returns an array of data. Using get_sub_field* instead of the_sub_field* stores that array into the variable $select_staff.

    Then in order to retrieve the user ID, query the $select_staff array. Note the use of brackets for the array rather than the previous typo with parentheses.

Viewing 4 posts - 1 through 4 (of 4 total)