0

I have created custom php file inside template directory with the name confirm_email.php in which user's status is updating when user click on confirmation link sent to users email. but when i am using wp_update_user() to update user_status from 0 to 1. But it is returning Http 500 internal server error.

<?php
$temp_dir="https://property-penang.com/wp-content/themes/wpresidence";

$url= $temp_dir."/confirm_email.php?id=".$_REQUEST['id']."&key=".$_REQUEST['key']."&type=return";
if(isset($_REQUEST['type'])){

$user_id = wp_update_user( array( 'ID' => $_REQUEST['id'], 'user_status' => 1) );

if ( is_wp_error( $user_id ) ) {
    // There was an error, probably that user doesn't exist.
    echo "Error is here";

} else {
    // Success!
    echo "User Email confirm";
}   

    }

else{

        $message="Username:".$_REQUEST['name']."
    Click on below link to confirm your email;
    ".$url;

    $subject="Email confirmation Link";
    $headers = "From: wordpress@property-penang.com" . "\r\n";

if(mail($_REQUEST['email'],$subject,$message,$headers)){
     echo "1";  
    }
else{
         echo "0";
}
    }
?>
  • Are you trying to load confirm_email.php directly? Then you're using WordPress functions despite not loading WordPress. You should handle this functionality through hooks, not its own file. – Jacob Peattie May 12 '18 at 10:27
  • Surely if you turn on PHP Debugging it will give you a more specific error to go off of. – Howdy_McGee May 12 '18 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.