Thursday, May 30, 2024
Wordpress Cheat Codes

WordPress cheat code to update User details from frontend

How to add custom meta title and meta description in Wordpress?

Hello to all, welcome to In this post, I will tell you, WordPress cheat code to update User details from frontend.

Today again, I am coming with WordPress cheat code to update User details from frontend and this is very easy and useful.

I am sharing these codes because, these codes are very simple but sometime simple thing takes very much time so.

With this post code, I am making frontend form and with that form, I will update login user details. I will hope this will be useful.

Here is the code for wordpress cheat code to update user details from frontend and please use this carefully into your WordPress theme’s template file:

if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {
global $current_user; // Get login user data
$args = array(
    'ID'         => $current_user->id,
    'user_email' => esc_attr( $_POST['user_email'] ),
    'user_nicename' => esc_attr( $_POST['user_nicename'] )
wp_update_user( $args ); // Update user data
<!-- Content -->
<div class="content">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="card">
                    <div class="card-header">
                        <div class="crd-flx">
                            <h2 class="card-title">My Profile</h2>
                    <div class="card-body">
                        <form class="My-profile" id="new_post" name="new_post" method="post" action="">
                            <div class="row">
                                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                    <div class="form-group">
                                        <input type='text' class="form-control" name="user_nicename" required value="<?php echo $current_user->user_nicename; ?>" />
                                    <div class="form-group">
                    <!--This is disabled because we can not change the Username-->
                                        <input disabled="disabled" type='text' class="form-control" name="username" value="<?php echo $current_user->user_login; ?>" />
                                    <div class="form-group">
                                        <input type='email' class="form-control" name="user_email" required value="<?php echo $current_user->user_email; ?>" />
                                    <div class="row">
                                        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                                            <div class="form-group">
                                                <input type="submit" value="Save" class="btn btn-custom login-btn pull-right"/>

                            <input type="hidden" name="action" value="new_post" />
                            <?php wp_nonce_field( 'new-post' ); ?>
<!-- /.content -->


This is it and if you have any query related to this post then please do comment.


Thank you

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.