Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get user information woocommerce

<?php 
//get information about user in wordpress :
// get first name, last name, adresse1, adress2, city, post code and phone


$current_user = wp_get_current_user();

$fname = get_user_meta( $current_user->ID, 'first_name', true );
$lname = get_user_meta( $current_user->ID, 'last_name', true );
$address_1 = get_user_meta( $current_user->ID, 'billing_address_1', true ); 
$address_2 = get_user_meta( $current_user->ID, 'billing_address_2', true );
$city = get_user_meta( $current_user->ID, 'billing_city', true );
$postcode = get_user_meta( $current_user->ID, 'billing_postcode', true );
$phone = get_user_meta( $current_user->ID, 'billing_phone', true );

echo $fname . "<BR>";
echo $lname . "<BR>";
echo $address_1 . "<BR>";
echo $address_2 . "<BR>";
echo $city . "<BR>";
echo $postcode . "<BR>";
echo $phone . "<BR>";

// simple form example :
?> 

 <div class="content-form">
<form action="<?php get_the_permalink() ?>" id="contact-form" method="POST">
    <div class="formGroup">
        <label for="contactFirstName" >Nom:</label>
        <input type="text" name="contactFirstName" id="contactFirstName" value="<?php echo($fname);?>" >
        <label for="contactLastName" >Prénom:</label>
        <input type="text" name="contactLastName" id="contactLastName" value="<?php echo($lname);?>" >
        <span class="error"></span>
    </div>
    <div class="formGroup">
        <label for="adress1" >Adresse:</label>
        <input type="text" name="adress1" id="adress1" value="<?php echo($address_1);?>" >
        <label for="adress2" >Adresse: <span>(Information complémentaire)</span></label>
        <input type="text" name="adress2" id="adress2" value="<?php echo($address_2);?>" >
        <label for="city" >Ville:</label>
        <input type="text" name="city" id="city" value="<?php echo($city);?>" >
        <label for="postCode" >Code Postal:</label>
        <input type="text" name="postCode" id="postCode" value="<?php echo($postcode);?>" >

        <span class="error"></span>
    </div>
    <div class="formGroup">
        <label for="phone" >Téléphone:</label>
        <input type="tel" name="phone" id="phone" value="<?php echo($phone);?>" >
        <label for="email" >Email:</label>
        <input type="email" name="email" id="email" value="<?php echo($current_user->user_email);?>" >
        <span class="error"></span>
    </div>
    <div class="formGroup">
        <label for="messageText" >Votre projet (détaillé au maximum) :</label>
        <textarea name="messageText" id="messageText" cols="50" rows="10" placeholder="Ecrivez votre message ici..."></textarea>
        <span class="error"></span>
    </div>
    <input type="hidden" name="submitted" id="submitted" value="true" >
    <input type="hidden" name="userIdentification" id="userIdentification" value="<?php echo( 'Identification du compte à partir duquel  l'email a etait envoyé. Nom: '.$current_user->first_name.'. Prénom: '.$current_user->last_name .'. Pseudo: '.$current_user->user_login .'. Email: '.$current_user->user_email )?>" >
    <input type="submit" value="Envoyer" >

    
    </form>
    </div>
 
PREVIOUS NEXT
Tagged: #user #information #woocommerce
ADD COMMENT
Topic
Name
4+8 =