wp_redirect not working after update_user_meta

Question

I have create a custom page to make users able to edit their profiles. every thing is OK but I do not know really why wp_redirect does not work???
.
my edit-profile-proccess.php
.

<?php

$user = wp_get_current_user();
$userID = $user->ID;

$has_error = false;
$has_success = false;
$message = array();
    
if(isset($_POST['edpr_profile_submit'])){
    if(! isset($_POST['security']) || ! wp_verify_nonce($_POST['security'],'edit-profile-nonce')){
        print('<p">be careful</p>');
    }else{
            
        $firstnameuser = sanitize_text_field($_POST['edpr_firstname']);
        $lastnameuser = sanitize_text_field($_POST['edpr_lastname']);
        
        
        //if( empty($firstnameuser) || empty($lastnameuser) || empty($emailuser) || empty($cellphoneuser) || $genderuser == 'nonete'  ){
        if( empty($firstnameuser) || empty($lastnameuser)  ){
            
            $has_error = true;
            $message[] = "fill all fields";
            
        }
        
        //if(!$has_error) {
        else {
            
            update_user_meta($userID,'first_name',$firstnameuser);
            update_user_meta($userID,'last_name',$lastnameuser);

            //$has_success = true;
            //$message[] = "updated successfully";
            
            $redirecturlll = site_url('/edit-profile/?editprofile=true');
            wp_redirect( $redirecturlll );
            exit;
               
            
        }
    
    
    }
}




// Never Delete The Following Line:
$usermeta = get_user_meta($userID);

.
my edit-profile.php
.

<?php /* Template Name: edit-profile */ ?>

<?php get_header(); ?>
        
<div class="mysignuppagebody">
        
<?php if ( !is_user_logged_in() ) { ?>
    
    <section class="top_message">
        <p>do login</p>
    </section>

<?php } else { ?>

    <?php include get_template_directory() . '/templates/edit-profile-proccess.php'; ?>
    
    <div class="mysignuppage">
                
        <?php if( $has_error ){ ?>
            <div class="myloginpage_message error">
                <?php foreach ($message as $item) { ?>
                <p><?php echo $item; ?></p>
                <?php } ?>
            </div>
        <?php } ?>
        <?php if( $has_success ){ ?>
            <div class="myloginpage_message success">
                <?php foreach ($message as $sitem) { ?>
                <p><?php echo $sitem; ?></p>
                <?php } ?>
            </div>
        <?php } ?>

        <form action="<?php echo get_permalink(); ?>" method="post" enctype="multipart/form-data" class="">
            
            <?php wp_nonce_field('edit-profile-nonce', 'security'); ?>

            <input type="text" value="<?php echo esc_attr($usermeta['first_name'][0]); ?>" name="edpr_firstname" required placeholder="first name *">
                
            <input type="text" value="<?php echo esc_attr($usermeta['last_name'][0]); ?>" name="edpr_lastname" required placeholder="last name *">

            <input type="submit" value="edit profile" name="edpr_profile_submit">

        </form>

    </div>
<?php } ?>  

</div>
        
        
<?php get_footer(); ?>
0
, user191919 1 year 2020-07-20T05:11:39-05:00 0 Answers 60 views 0

Leave an answer

Browse
Browse