Support

Account

Home Forums ACF PRO Getting Field Value in functions.php

Solving

Getting Field Value in functions.php

  • I created a custom field for the user form and am looking to display it on the users profile page on the front end using a hook. However, after a lot of trial and error, I can’t seem to get the field value to display. Here’s what I have so far. it’s a simple text field I’m looking to display.

    add_action( 'wc_memberships_before_my_memberships', 'customerid' );
        function customerid() {
            echo "<p>Customer ID: "; echo get_field('userid'); echo "</p>";
        }
  • Does this wc hook wc_memberships_before_my_memberships pass any values to your action, like the user’s ID?

    In order to get a field from a user you need to provide the correct ID. The correct ID is "user_{$user_id)" see the Get a value from different objects section of https://www.advancedcustomfields.com/resources/get_field/

  • were you able to figured this out?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Getting Field Value in functions.php’ is closed to new replies.