Home Forums General Issues Checking for values in an AC-field


Checking for values in an AC-field

  • Here is what i want to do, and i am currently very stuck figuring this out
    – Hook into post login
    – Check if the current user has data stored in MyCertificates
    – if NOT, make API call, get image, sideload image, store image for the current user’s MyCertificates-field
    – if IT DOES, do nothing… the image is already there

    I have figured i need to make a user-group with firstname, lastname and image-field (?)

  • The wp_login hook runs after a user has logged in. This would be where you’d want to do what you are trying to do.

  • Yes, the wp_login_hook is what i use for that.

    I cannot, with the DOCs, understand how to attach an image to a user-field….
    Maybe there are somebody with a few pointers here ?
    And is my assumption of doing a User-group with firstname, lastname and image-field correct?

  • You set up a acf field group with an image field that has the location rule

    User Form is equal to All (or add/edit or whatever place you want it to appear)

    You side load the image, this returns and image attachment ID
    you then update the ACF field with that ID

    // use field key for fields that do not already have values
    // 3rd parameter is the post id where to store the value, in this case it is a user
    update_field('field_XXXXX', $attachment_id, 'user_'.$user->ID);
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.