<?php $user = array( 'user' => array( "id" => "johndoe", "displayname" => "John Doe", "email" => "[email protected]", "avatar" => "//gravatar.com/avatar/e5fb96fe7ec4ac3d4fa675422f8d1fb9", "is_admin" => true, ), ); $message = base64_encode(json_encode($user)); $timestamp = time(); $signature = sha1('MY_SECRET_MUUT_KEY_GOES_HERE' . ' ' . $message . ' ' . $timestamp); ?>
<?php $muutuser = array( 'user' => array( "id" => $modx->username, "displayname" => $modx->fullname, "email" => $modx->email, "avatar" => $modx->photo, "is_admin" => false, ), ); $message = base64_encode(json_encode($muutuser)); $timestamp = time(); $signature = sha1('MY_SECRET_MUUT_KEY_GOES_HERE' . ' ' . $message . ' ' . $timestamp); ?>
<?php $profile = $modx->user->getOne('Profile'); $muutUser = array( 'user' => array( "id" => $modx->user->get('username'), "displayname" => return $profile ? $profile->get('fullname') : '', "email" => return $profile ? $profile->get('email') : '', "avatar" => return $profile ? $profile->get('photo') : '', "is_admin" => true, ), ); $message = base64_encode(json_encode($muutUser)); $timestamp = time(); $signature = sha1('MY_SECRET_KEY' . ' ' . $message . ' ' . $timestamp); ?>
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>[[++site_name]] - [[*pagetitle]]</title> <base href="[[++site_url]]" /> [[$muutHeader]] </head> <body> [[muutUserBridge]] [[$muutForumEmbed]] </body> </html>
<link rel="stylesheet" href="//cdn.muut.com/1/moot.css" /> <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> <script src="//cdn.muut.com/1/moot.min.js"></script>
<a id="embedded-muut-forum" href="https://muut.com/i/sanctuary">Sanctuary Community</a> <script> $("#embedded-muut-forum").muut({ login_url: 'http://sanctuaryinternational.com/community/index.php', api: { key: 'MY_SHORT_MUUT_KEY_GOES_HERE', message: '<?php echo $message; ?>', timestamp: '<?php echo $timestamp; ?>', signature: '<?php echo $signature; ?>', } }); </script>
This question has been answered by syberknight. See the first response.
<?php $muutUser = array( 'user' => array( "id" => "THE_MODX_USERNAME_NEEDS_TO_GO_HERE", "displayname" => "THE_MODX_FULLNAME_NEEDS_TO_GO_HERE", "email" => "THE_MODX_EMAIL_NEEDS_TO_GO_HERE", "avatar" => "THE_MODX_PHOTO_NEEDS_TO_GO_HERE", ), );
The current user can be retrieved in the API via the $modx->user reference. For example, this snippet outputs the username of the user: return $modx->user->get('username'); Note that to grab Profile fields, you'll need to first get the modUserProfile object via the Profile alias. For example, this snippet grabs the email of the user and returns it: $profile = $modx->user->getOne('Profile'); return $profile ? $profile->get('email') : ''; If the User is not logged in, $modx->user will still be available as an object, but will return 0 as the ID and (Anonymous) as the username.
$modx->user->get('username') $profile = $modx->user->getOne('Profile'); return $profile ? $profile->get('fullname') : '' return $profile ? $profile->get('email') : '' return $profile ? $profile->get('photo') : ''
<?php $profile = $modx->user->getOne('Profile'); return $profile ? $profile->get('email') : '';
<?php // The current user can be retrieved in the API via the $modx->user reference. // For example, this snippet outputs the username of the user: $modx_username = $modx->user->get('username'); $profile = $modx->user->getOne('Profile'); $profile_email = $profile ? $profile->get('email') : 'no email found'; $output ='<p>Username: '. $modx_username .' - ( '. $profile_email .' )</p>'; return $output;
<?php $username = $modx->user->get('username'); $profile = $modx->user->getOne('Profile'); $email = $profile->get('email'); $fullname = $profile->get('fullname'); $photo = $profile->get('photo'); $muutuser = array( 'user' => array( "id" => "$username", "displayname" => "$fullname", "email" => "$email", "avatar" => "//sanctuaryinternational.com/$photo", "is_admin" => false, ), ); $message = base64_encode(json_encode($muutuser)); $timestamp = time(); $signature = sha1('MY_SECRET_MUUT_KEY_GOES_HERE' . ' ' . $message . ' ' . $timestamp); echo ' <link rel="stylesheet" href="//cdn.muut.com/1/moot.css" /> <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> <script src="//cdn.muut.com/1/moot.min.js"></script> <a id="embedded-muut-forum" href="//muut.com/i/sanctuary">Sanctuary Community</a> <script> $("#embedded-muut-forum").muut({ login_url: "//sanctuaryinternational.com/the_login_page.html", api: { key: "MY_SHORT_MUUT_KEY_GOES_HERE", message: "'.$message.'", timestamp: "'.$timestamp.'", signature: "'.$signature.'" } }); </script> ';