Support

Account

Home Forums Front-end Issues Custom Front End Regsistration and ACF

Unread

Custom Front End Regsistration and ACF

    • mmdwc

    • August 7, 2019 at 3:25 am

    Hello

    I’m using on my website a custom front end registration to let users register directly front my website.

    I have 4 fields, Username, e-mail, password and confirm password.

    In my Back Office, I have a group field “user” with custom fields for registered users.

    “first name”, “last name”, “function”, “country” (selectlist) etc etc…

    what I’m trying to do is to ask the user when on the registration form to fill some of my custom fields on registration.

    I know how to use acf_form() to create or update custom fiels from the front end, but I don’t know how to update my ACF field when user is registrating.

    here is my registration form :

    <?php
    if ( $_POST ) {
    
    $error = 0;
    
    /* USERNAME ------------------------------------------------------------------------*/
    
    $username = esc_sql($_REQUEST['username']); 
    
    if ( strlen($username) < 6 ) {
    
    	echo "<div class='alert_form'>Pas assez de caractère</div>"; 
    
    	$error = 1;
    
    }
    
    if ( preg_match('/\s/',$username) ) {
    
    	echo "<div class='alert_form'>pas d'espace</div>"; 
    
    	$error = 1;
    
    }
    
    /* EMAIL ------------------------------------------------------------------------*/
    
    $email = esc_sql($_REQUEST['email']);
    
    if ( !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", $email) ) { 
    
    	echo "<div class='alert_form'>Please enter a valid email</div>"; 
    	$error = 1;
    
    }
    
    /* MOT DE PASSE ------------------------------------------------------------------------*/
    
    $password = esc_sql($_REQUEST['password']); 
    
    /* VALIDATION ------------------------------------------------------------------------*/
    
    if ( $error == 0 ) {
    
    	$status = wp_create_user( $username, $password, $email ); 
    
    }
    
    }
    
    if ( $error != 2 ) { ?> 
    
    <?php if(get_option('users_can_register')) { ?>
    
    <form id="register_form" action="" method="post"> 
    
    	<div class="form_row">
    
    		<input type="text" name="username" required placeholder="Identifiant" value="<?php if( ! empty($username) ) echo $username; ?>" />
    	
    	</div>
    	
    	<div class="form_row"> 
    
    		<input type="email" name="email" required placeholder="Adresse e-mail" value="<?php if( ! empty($email) ) echo $email; ?>" /> 
    
    	</div>
    
    	<div class="form_row"> 
    
    		<input id="password" type="password" name="password" required placeholder="Mot de Passe" value="<?php if( ! empty($password) ) echo $password; ?>"/>
    
    	</div>
    
    	<div class="form_row"> 
    
    		<input id="password_check" type="password" name="password_check" required placeholder="Répétez votre Mot de Passe" value="<?php if( ! empty($password_check) ) echo $password_check; ?>" />
    
    	</div>
    
    	<div id="password-strength-status"><div class="alert_form"></div></div>
    
    	<div class="form_row row_submit">
    
    		<input type="submit" id="register-submit-btn" name="submit" value="S'inscrire" /> 
    
    	</div>
    
    </form>
    
    <?php } else {
    
    echo "Registration is currently disabled. Please try again later."; 
    
    }
    
    } ?>

    can anybody help me with this ?
    any ideas or tutorials ?

    thanks

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.