(1) It's possible to display custom fields / content there by using this code snippet:
add_action('b2bking_subaccount_tab_right', function($user){
// your code to display the custom fields here
}, 10, 1);
I can help further with code to show the custom fields if you can give me more details about the code you used to add fields.
(2) I don't currently have a direct way to do this. I think the best way would be to either use a plugin with that sort of function (For editing user meta), or a code guide such as this one here:
add_filter('b2bking_custom_field_meta', function($field_name){ // you can set a custom user meta key here if ($field_name === 'b2bking_Company/Department'){ $field_name = 'Company/Department'; } if ($field_name === 'b2bking_store_id'){ $field_name = 'storeid'; } return $field_name; }, 10, 1);
for #2, If I used an app or the code, would this be able to pull the data from what was entered into the additional data fields when the sub account was created or would I also need to enter the data manually within wordpress?
Hi there,
(1) It's possible to display custom fields / content there by using this code snippet:
I can help further with code to show the custom fields if you can give me more details about the code you used to add fields.
(2) I don't currently have a direct way to do this. I think the best way would be to either use a plugin with that sort of function (For editing user meta), or a code guide such as this one here:
https://rudrastyh.com/wordpress/custom-fields-in-user-profiles.html
Kind regards,
Stefan
Hi, below is the code I used to add the fields which I would like to display when viewing sub accounts data
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('Company/Department','b2bking'); ?>
</div>
<input type="text" class="b2bking_subaccounts_new_account_container_content_element_text" name="b2bking_Company/Department" placeholder="<?php esc_attr_e('Enter the Company or Department here...','b2bking'); ?>" <?php if($user_id !== 0){echo 'value="'.esc_html(get_user_meta($user_id,'Company/Department', 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_Company/Department', '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_Company/Department'){
$field_name = 'Company/Department';
}
if ($field_name === 'b2bking_store_id'){
$field_name = 'storeid';
}
return $field_name;
}, 10, 1);
for #2, If I used an app or the code, would this be able to pull the data from what was entered into the additional data fields when the sub account was created or would I also need to enter the data manually within wordpress?
You could add this code to your site for the 2 fields you added there:
It should show the Store ID and company like this:
If you used an app / code / plugin it should be able to pull the data. That data is user metadata.
For example to get the Store ID field, the meta key is "storeid". Any plugin that can modify user metadata would understand that meta key.
Perfect, Love your work!