WordPress.org

Ready to get started?Download WordPress

Forums

User Photo
Front End (7 posts)

  1. ibykus86
    Member
    Posted 1 year ago #

    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:
    <?php
    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?

    http://wordpress.org/extend/plugins/user-photo/

  2. deutschwulf
    Member
    Posted 1 year ago #

    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!)

  3. Arvid de Jong
    Member
    Posted 1 year ago #

    Hi,

    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.

    Regards

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

  4. KevinMcCall
    Member
    Posted 11 months ago #

    Hi Arvid,

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

  5. ChiefEkene
    Member
    Posted 11 months ago #

    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 http://www.nkanueliteforum.com/activity/

  6. Arvid de Jong
    Member
    Posted 11 months ago #

    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">
            <tr>
              <td class="links" width="205"><strong>Profile foto</strong></td>
              <td width="10">:</td>
              <td class="rechts" width="205"><?php
    		  if(userphoto_exists($current_user)){
    		  userphoto($current_user);
    		  ?>
                <input type="checkbox" name="userphoto_delete" id="userphoto_delete" />
                Delete current photo?
                <?php
    		  }
    		 ?>
                <input type="file" id="userphoto_image_file" name="userphoto_image_file">
                <br></td>
            </tr>
            <tr>
              <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>
            </tr>
            <tr>
              <td class="links"><strong>Password again</strong></td>
              <td width="10">:</td>
              <td class="rechts"><input name="pass2" type="password" id="pass2" /></td>
            </tr>
            <tr>
              <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>
            </tr>
            <tr>
              <td class="links"><strong>First name</strong></td>
              <td>:</td>
              <td class="rechts"><input name="first-name" type="text" id="first-name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" /></td>
            </tr>
            <tr>
              <td class="links"><strong>E-mail</strong></td>
              <td>:</td>
              <td class="rechts"><input name="email" type="email" id="email" value="<?php the_author_meta( 'user_email', $current_user->ID ); ?>" /></td>
            </tr>
          </table>
          <?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>
        </form>

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

    <?php
    /* Get user info. */
    global $current_user, $wp_roles;
    get_currentuserinfo(); 
    
    /* 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'] ) ) );
            else
                $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');
            else{
    			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() );
            exit;
        }
    }
    ?>

    I hope it helps

  7. filippusvandijk
    Member
    Posted 8 months ago #

    Arvid,
    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.
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags