Front Side Support
-
Hej,
I just wanted to share some code that can be helpful for others to allow adding front side edit option with a shortcode.
function editavatar_func($atts) { extract(shortcode_atts(array( 'size' => '250' ), $atts)); global $user_ID; if ($user_ID) { $user_info = get_userdata($user_ID); $id = $user_info->ID; } if(isset($_POST['user_avatar_edit_submit'])) { do_action('edit_user_profile_update', $id); } ob_start(); wp_nonce_field( 'simple_local_avatar_nonce', '_simple_local_avatar_nonce', false ); $nonce = ob_get_contents(); ob_end_clean(); $output = '<form id="your-profile" action="" method="post">'; $output .=$nonce ; $output .=' <div class="avatar-wrap">'; $output .=' <div class="avatar">'; $output .= get_avatar( $id ,$size); $output .=' </div>'; $output .= '<input type="file" name="simple-local-avatar" id="simple-local-avatar" />'; $output .=' </div>'; $output .= '<input type="submit" name="user_avatar_edit_submit" value="OK"/>'; $output .= '</form>'; $output .='<script type="text/javascript">var form = document.getElementById(\'your-profile\');form.encoding = \'multipart/form-data\';form.setAttribute(\'enctype\', \'multipart/form-data\');</script>'; return $output; } add_shortcode('editavatar', 'editavatar_func');
https://www.ads-software.com/extend/plugins/simple-local-avatars/
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Front Side Support’ is closed to new replies.