Tagged: ,

Viewing 2 reply threads
  • Author
    Posts
    • #5495

      I am creating user profile pages on the front end of the site.

      I’m allowing them to upload a cover photo as a background image for their profile.

      i’m following this to get the profile image uploaded to the profile
      : https://piklist.com/user-guide/tutorials/displaying-images-upload-field/

      I have the field in the user’s folder in a plugin.

      <?php
      /*
      Title: Profile Cover Photo
      Description: Displays on your profile as a background cover image
      Capability: manage_options
      */
       
      // image upload
      piklist('field', array(
        'type' => 'file'
        ,'field' => 'cover_image'
        ,'label' => 'Upload image'
      ));
      
      ?>

      I can upload the image just fine.

      However, when I go to get the data back, I can’t get the id.
      ($author code is not referenced below but is a valid variable in this instance)

      $image_ids = get_user_meta($author->ID, 'cover_image');
       print_r($image_ids);
      

      I get on the page:

      Array ( )

      Any suggestions?

    • #5496

      Update: I took out the key “cover_image” and noticed there’s a item called “my_image”. Turns out it is the same as what I added.

      How do I change the key for it? I’d rather it be semantic and thought using the field key in piklist would do just that.

    • #5500
      Steve
      Keymaster

      @friendlyfire3– When creating forms for the front-end of your website, you need to tell Piklist the scope of each field…where to save the data.

      Add this:

      'scope' => 'user_meta'
      

      The field ‘my_image’ must be left over from something else. Piklist will save the field exactly how you specify it

Viewing 2 reply threads
  • You must be logged in to reply to this topic.