Buy B2BKing
$199 $149
You may want to add custom fields connected to user meta keys, available when a new subaccount is created or edited.
You can use the following snippet:
add_action('b2bking_custom_new_subaccount_fields', function($user_id = 0){ ?> <br> <div class="b2bking_subaccounts_new_account_container_content_element"> <div class="b2bking_subaccounts_new_account_container_content_element_label"> <?php esc_html_e('Store Code','b2bking'); ?> </div> <input type="text" class="b2bking_subaccounts_new_account_container_content_element_text" name="b2bking_store_code" placeholder="<?php esc_attr_e('Enter the store code here...','b2bking'); ?>" <?php if($user_id !== 0){echo 'value="'.esc_html(get_user_meta($user_id,'storecode', true)).'"';}?>> </div> <div class="b2bking_subaccounts_new_account_container_content_element b2bking_subaccount_horizontal_line"> <div class="b2bking_subaccounts_new_account_container_content_element_label"> <?php esc_html_e('Store ID','b2bking'); ?> </div> <input type="text" class="b2bking_subaccounts_new_account_container_content_element_text" name="b2bking_store_id" placeholder="<?php esc_attr_e('Enter the store id here...','b2bking'); ?>" <?php if($user_id !== 0){echo 'value="'.esc_html(get_user_meta($user_id,'storeid', true)).'"';}?>> </div> <?php }); add_filter('b2bking_custom_new_subaccount_field_names', function($fields){ $fields = array('b2bking_store_code', 'b2bking_store_id'); return $fields; }, 10, 1); add_filter('b2bking_custom_field_meta', function($field_name){ // you can set a custom user meta key here if ($field_name === 'b2bking_store_code'){ $field_name = 'storecode'; } if ($field_name === 'b2bking_store_id'){ $field_name = 'storeid'; } return $field_name; }, 10, 1);
Explaining the snippet:
This snippet adds 2 fields there visually:
These fields are connected to the 'storecode' and 'storeid' user meta keys in our example.
Powered by BetterDocs