Support

Account

Home Forums Front-end Issues How to Display fields on frontend w snippet

Solved

How to Display fields on frontend w snippet

  • Hello all,

    I would like to ask help.

    I tried so many solutions but nothing work.

    I created a custom tab for WooCommerce (My Profile) name as “Üzleteim”, with CodeSnippets.

    Here is the code:

    add_action( 'init', 'register_uzleteim_endpoint');
    
    /**
     * Register New Endpoint.
     *
     * @return void.
     */
    function register_uzleteim_endpoint() {
    	add_rewrite_endpoint( 'uzleteim', EP_ROOT | EP_PAGES );
    }
    
    add_filter( 'query_vars', 'uzleteim_query_vars' );
    
    /**
     * Add new query var.
     *
     * @param array $vars vars.
     *
     * @return array An array of items.
     */
    function uzleteim_query_vars( $vars ) {
    
    	$vars[] = 'uzleteim';
    	return $vars;
    }
    
    add_filter( 'woocommerce_account_menu_items', 'add_uzleteim_tab' );
    
    /**
     * Add New tab in my account page.
     *
     * @param array $items myaccount Items.
     *
     * @return array Items including New tab.
     */
    function add_uzleteim_tab( $items ) {
    
    	$items['uzleteim'] = 'Üzleteim';
    	return $items;
    }
    
    add_action( 'woocommerce_account_uzleteim_endpoint', 'add_uzleteim_content' );
    
    /**
     * Add content to the new tab.
     *
     * @return  string.
     */
    function add_uzleteim_content() {
    	
    }
    	
    

    I would like to show here at

    function add_uzleteim_content() {
    	
    }

    some information from user profile. I already added to user profile the information fields.
    But I can not display the data on frontend.

    The “Kapcsolattartó neve” is “kapcsolattarto_neve”. I tried shortcodes but did not work, and edit in CodeSnippet but there were some error always.

    Thank you,
    R

  • Okay. After more than 20 hours I already did it…

    😀

    Here is the code:

    $user_ID = get_current_user_id(); 
    the_field('kapcsolattarto_neve', 'user_'. $user_ID);
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.