Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode('wcfm_vendor_registration_custom_field', function ($attr) {
- global $post;
- $custom_field_label = $attr['label'] ?? '';
- if(!$custom_field_label) return;
- $store_id = '';
- if ( isset( $attr['id'] ) && ! empty( $attr['id'] ) ) {
- $store_id = absint( $attr['id'] );
- }
- if ( wcfm_is_store_page() ) {
- $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
- $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
- $store_id = 0;
- if ( ! empty( $store_name ) ) {
- $store_user = get_user_by( 'slug', $store_name );
- $store_id = $store_user->ID;
- }
- }
- if ( is_product() ) {
- $store_id = $post->post_author;
- }
- if( !$store_id ) return;
- $wcfmmp_addition_info_fields = wcfm_get_option('wcfmvm_registration_custom_fields', array());
- if (empty($wcfmmp_addition_info_fields)) return;
- $wcfmvm_custom_infos = (array) get_user_meta($store_id, 'wcfmvm_custom_infos', true);
- $field_value = '';
- foreach ($wcfmmp_addition_info_fields as $wcfmvm_registration_custom_field) {
- if (!isset($wcfmvm_registration_custom_field['enable'])) continue;
- if (!$wcfmvm_registration_custom_field['label']) continue;
- if ($wcfmvm_registration_custom_field['label'] !== $custom_field_label) continue;
- $field_name = sanitize_title($wcfmvm_registration_custom_field['label']);
- $field_value = isset($wcfmvm_custom_infos[$field_name]) ? $wcfmvm_custom_infos[$field_name] : '';
- break;
- }
- if ($field_value) {
- ?>
- <div class="store_info_parallal wcfmmp_store_header_custom">
- <p><?php echo $custom_field_label; ?>: <span><?php echo $field_value; ?></span></p>
- </div>
- <?php
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement