How can I call a specific file (via php) by referencing the logged-in username?
-
I want to setup a page that will display different content for each registered user of my site who falls within a specially-created user role (‘map_user’). So, for example, if a site user who is in the ‘map_user’ category logs into the site they’re automatically forwarded to a specific page. This page then refers to their username, calls specific external content (html) based on that username and includes it in the page.
I’ve managed to solve the first problem (forwarding users based on their user role) through a combination of plugins and functions. But I’m struggling with the second part, once they’ve arrived at the destination page.
I’ve created a template for the page and included the following php within it:
<?php if ( is_array( $user->roles ) && in_array( 'map_user', $user->roles ) ) : ?> <div id="mapContent"> <?php require("/mapping/{$user->data->user_login}.html/"); ?> </div> <?php endif; ?>
Where am I going wrong? (My php skills are very much of the copy/paste or “steal and adapt” variety, so I’m prepared to have stupid mistakes pointed out to me ?? )
- The topic ‘How can I call a specific file (via php) by referencing the logged-in username?’ is closed to new replies.