Support » Plugin: Pods - Custom Content Types and Fields » How to save Pods Avatar on Front End Profile

  • Resolved awpu

    (@awpu)


    I can display a Pod Avatar form field within my own form using:

    $pods = pods( 'user' );
    echo $pods->form( array('fields_only' => true, 'local-avatar') );

    However, I can’t figure out how to save it. First, it adds a hidden input with a fieldname I can’t decipher. I can use a foreach loop on the $_POST array to find the name, but it still doesn’t save:

    foreach($_POST as $postName => $postValue) {
        if (strpos($postName, 'local-avatar')) {
    	  $pod = pods('user');
              $pod->save($postValue, $current_user->ID);
    	  break;
        }
    }

    What’s the correct way to save the avatar for the user?

    Thanks.

    • This topic was modified 10 months, 1 week ago by  awpu.
Viewing 2 replies - 1 through 2 (of 2 total)
  • OK, figured this out if someone else needs it:

    if (key($_POST['local-avatar'])) {
        $pod = pods('user');
        $pod->save('local-avatar', key($_POST['local-avatar']), $current_user->ID);
    }
    • This reply was modified 10 months ago by  awpu.
    Plugin Author Jim True

    (@jimtrue)

    I’m glad you figured this out and sorry we missed your question before you solved it.

    I blame the holidays.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to save Pods Avatar on Front End Profile’ is closed to new replies.