Support » Plugin: User Photo » Front End

  • Hi, like your plugin a lot! I really think it is awesome!

    But two things to make it the best ever:

    What about a front end Shortcode?

    I tryed this:
    if(function_exists(‘userphoto_exists’)) {
    if(userphoto_exists($userdata->ID)){ userphoto_thumbnail($userdata->ID);
    }else{ echo get_avatar($userdata->user_email, ); }

    For getting the avatar, if there is one… but it does not appear….

    for upload i tryed this:

    <?php if($userdata->userphoto_image_file){ ?>
    <input type=”checkbox” name=”userphoto_delete” id=”userphoto_delete” /> Delete existing photo?
    <?php }else{ ?>
    <input type=”file” id=”userphoto_image_file” name=”userphoto_image_file”>
    <?php } ?>

    kinda worked. but it’s out of layout. and uploaded pictures can’t get into the size they belong….

    so what can i do, at all?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’ve got a similar problem. I was able to easily retrieve the image with this:

    <?php userphoto_thumbnail($current_user->id) ?>

    However, I’m still struggling trying to upload a photo from the frontend (though your delete solution works, kudos!)


    I tried also several things to upload @ the frontend but no results.
    It seems the system does not see the upload $_FILES['userphoto_image_file'].

    Does someone have a workaround?

    Ps. The delete function is working perfectly.


    I forgot the following line in my form. <form enctype="multipart/form-data" >

    Hi Arvid,

    Can you share the code that you were able to make work?

    I just want my users avatar to display at the front end and to be able to upload avatar from the frontend. i equally want my users to be able to upload avatar on registration page. am using buddypress and wildcommunity theme to build a small social network I am using the plugin but i don’t know php, so i don’t even know where and how to place those shortcodes on the plugins page. please i really need help
    This is my sites link

    Hi Kevin,

    Here is my code:

    On the page

    <form action="<?php the_permalink(); ?>" method="post" enctype="multipart/form-data" id="adduser">
          <table class="leden">
              <td class="links" width="205"><strong>Profile foto</strong></td>
              <td width="10">:</td>
              <td class="rechts" width="205"><?php
                <input type="checkbox" name="userphoto_delete" id="userphoto_delete" />
                Delete current photo?
                <input type="file" id="userphoto_image_file" name="userphoto_image_file">
              <td class="links"><strong>Password</strong></td>
              <td width="10">:</td>
              <td class="rechts"><input name="pass1" type="password" id="pass1" />
                (min. 4 chars)</td>
              <td class="links"><strong>Password again</strong></td>
              <td width="10">:</td>
              <td class="rechts"><input name="pass2" type="password" id="pass2" /></td>
              <td class="links"><strong>Last name</strong></td>
              <td width="10">:</td>
              <td class="rechts"><input name="last-name" type="text" id="last-name" value="<?php the_author_meta( 'last_name', $current_user->ID ); ?>" /></td>
              <td class="links"><strong>First name</strong></td>
              <td class="rechts"><input name="first-name" type="text" id="first-name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" /></td>
              <td class="links"><strong>E-mail</strong></td>
              <td class="rechts"><input name="email" type="email" id="email" value="<?php the_author_meta( 'user_email', $current_user->ID ); ?>" /></td>
          <?php echo $referer; ?>
          <?php wp_nonce_field( 'vdsgvsdgcs' ) ?>
          <input name="action" type="hidden" id="action" value="update-user" />
          <a class="button mb30" href="javascript:;" onclick="document.getElementById('adduser').submit();">save</a>

    This script does the update and you can put it above the form:

    /* Get user info. */
    global $current_user, $wp_roles;
    /* Load the registration file. */
    require_once( ABSPATH . WPINC . '/registration.php' );
    $error = array();
    /* If profile was saved, update profile. */
    if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) {
        /* Update user password. */
        if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {
            if ( $_POST['pass1'] == $_POST['pass2'] )
                wp_update_user( array( 'ID' => $current_user->ID, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );
                $error[] = __('The passwords you entered do not match.  Your password was not updated.', 'profile');
        /* Update user information. */
        if ( !empty( $_POST['email'] ) ){
            if (!is_email(esc_attr( $_POST['email'] )))
                $error[] = __('The Email you entered is not valid.  please try again.', 'profile');
            elseif(email_exists(esc_attr( $_POST['email'] )) != $current_user->ID && email_exists(esc_attr( $_POST['email'] )) != false)
                $error[] = __('This email is already used by another user.  try a different one.', 'profile');
    			wp_update_user( array ('ID' => $current_user->ID, 'user_email' => esc_attr( $_POST['email'] )));
        if ( !empty( $_POST['first-name'] ) )
            update_user_meta( $current_user->ID, 'first_name', esc_attr( $_POST['first-name'] ) );
        if ( !empty( $_POST['last-name'] ) )
            update_user_meta($current_user->ID, 'last_name', esc_attr( $_POST['last-name'] ) );
        if ( !empty( $_POST['description'] ) )
            update_user_meta( $current_user->ID, 'description', esc_attr( $_POST['description'] ) );
        /* Redirect so the page will show updated info.*/
      /*I am not Author of this Code- i dont know why but it worked for me after changing below line to if ( count($error) == 0 ){ */
        if ( count($error) == 0 ) {
            //action hook for plugins and extra fields saving
           // do_action('edit_user_profile_update', $current_user->ID);
            wp_redirect( get_permalink() );

    I hope it helps

    Can I add some script to a page to give the user the possibility to just upload a user photo?
    I am using wp-members to show and update member info.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Front End’ is closed to new replies.