最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Map Custom Registration Fields to Wordpress User Roles

programmeradmin3浏览0评论

How do I map these custom fields to the user profile?

Desired Functionality:
if selected 'Consumer' user role should be the 'Default- WordPress Role'
if selected 'Wholesale Buyer' user role should be 'Administrator'

Here's - What I have so far?

function iconic_get_account_fields() {
    return apply_filters( 'iconic_account_fields', array(
        'user_url' => array(
            'type'        => 'select',
            'label'   => __( 'Select Field', 'iconic' ),
            'options' => array(
                '' => __( 'Select Customer', 'iconic' ),
                1  => __( 'Consumer', 'Consumer' ),
                2  => __( 'Wholesale Buyer', 'Wholesale' ),
            ),
            'required'    => true,
        ),
    ) );
}
/**
 * Add fields to the registration form and account area.
 */
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', 10 ); // register form
add_action( 'woocommerce_edit_account_form', 'iconic_print_user_frontend_fields', 10 ); // my account
发布评论

评论列表(0)

  1. 暂无评论