Ok, so this sounds a little complex, but in theory should be easy.
What I'm trying to achieve:
ACF data is pulled from a WP page which has the same name as the current logged in user.
Basically I will have a WP page set up for each company. I will create a login for each company with an appropriate username. The name of the company page will be the exact same name as the username I create. It will have Advanced Custom Fields entered with data.
I want to dynamically pull in the ACF data from the company page based on the current user logged in into my page template.
So if company A are logged in, I want them to view the custom fields from company A's page. Company B log in and view the custom fields from the company B page.
So far, I have this:
<?php
global $user_login;
get_currentuserinfo();
$username = $current_user->user_login;
$other_page = $username;
?>
<p><?php the_field('my_custom_field', $other_page); ?></p>
Which in theory should work, but it just doesn't.
I can check the current username of the logged in user and echo it which returns the correct username just fine on the page.
I can also add a page ID by adding the page ID like this: $other_page = 890;
and it pulls in the custom field data from the correct company page (890 being one of the company pages).
So everything works as it should independently, just not when I want to use the logged in username as the name of the page (namely $other_page).
I'm baffled with this so any help would be greatly appreciated.