Wordpress get user meta function
<p>I'm using a couple of plugins to integrate with our LDAP/AD server - that plugin adds a bit of user meta when it successfully auths/creates a wp user. I'm also using the Ultimate Members plugin to control roles etc.</p>

<p>What I need to do is ensure anyone that signs in with their ldap creds gets assigned the ldap UM role. So here's the PHP I got thus far.</p>

<pre><code>global $ultimatemember;
global $user_ID;
$key = 'ad_integration_account_suffix';
$single = true;
$ldap_user=get_user_meta( $user_ID, $key, $single ); // core WP coe to get a users meta info - we are assigning it a variable
echo '&lt;p&gt;The '. $key . ' value for user id ' . $user_ID . ' is: ' . $ldap_user . '&lt;/p&gt;'; // some debug stuff - take this out
um_fetch_user( $user_ID ); // set UM user id to retrieve
   if($ldap_user !== '')  { // if the ldap user key is not null then its populated and thus this user is a member of AD
 $ultimatemember-&gt;user-&gt;set_role('ldap_user'); // so set the UM user to be a member of the ldap_user role/group.
    } 
</code></pre>

<p>Now, I think there's some issues with the above ie I assume that it also needs to be wrapped in a function? Where do I stick this php snippet so its called upon sign-in? I also probably should first check to see if the user is already in the ldap_user group and if so we don't need to continue with the rest of the checks/set's etc.</p>