Woo-commerce Registration form add otp as custom f

2019-08-03 22:28发布

问题:

I want to add otp when user register on woo-commerce registration page, i have added custom field for phone number but i am not able to get any sources for otp in word-press i have my own API please if someone can share any resource for finding it

It will be very helpful ...

function iconic_get_account_fields() {
    return apply_filters( 'iconic_account_fields', array(
        'user_url' => array(
            'type'        => 'text',
            'label'       => __( 'Phone' ),
            'placeholder' => __( 'E.g. 9861234567', 'iconic' ),
            'required'    => true,
        ),
    ) );
}
function iconic_print_user_frontend_fields() {
    $fields = iconic_get_account_fields();
 
    foreach ( $fields as $key => $field_args ) {
        woocommerce_form_field( $key, $field_args );
    }
}
 
add_action( 'woocommerce_register_form', 'iconic_print_user_frontend_fields', 1 );

add_action( 'woocommerce_edit_account_form', 'iconic_print_user_frontend_fields', 10 ); // my account

function iconic_print_user_admin_fields() {
    $fields = iconic_get_account_fields();
    ?>
    <h2><?php _e( 'Additional Information', 'iconic' ); ?></h2>
    <table class="form-table" id="iconic-additional-information">
        <tbody>
        <?php foreach ( $fields as $key => $field_args ) { ?>
            <tr>
                <th>
                    <label for="<?php echo $key; ?>"><?php echo $field_args['label']; ?></label>
                </th>
                <td>
                    <?php $field_args['label'] = false; ?>
                    <?php woocommerce_form_field( $key, $field_args ); ?>
                </td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
    <?php
}
 
add_action( 'show_user_profile', 'iconic_print_user_admin_fields', 30 ); // admin: edit profile
add_action( 'edit_user_profile', 'iconic_print_user_admin_fields', 30 );

.