Skip to content

Instantly share code, notes, and snippets.

@PaulHughes01
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save PaulHughes01/2d15bbd21bc8855fb369 to your computer and use it in GitHub Desktop.

Select an option

Save PaulHughes01/2d15bbd21bc8855fb369 to your computer and use it in GitHub Desktop.
Adding a second forum page to a website
<?php
/**
* muut-second-forum-page.php
*
* Template Name: Muut Second Forum Template
*
* @package Muut
* @copyright 2014 Muut Inc
*/
add_filter( 'muut_requires_muut_resources', '__return_true' );
get_header();
$data = array();
// FED-ID CODE
if ( !is_user_logged_in() ) {
$data = array( 'user' => array() );
} else {
$user = wp_get_current_user();
$key = muut()->getOption( 'subscription_api_key' );
$display_name = $user->display_name;
$avatar = get_user_meta( $user->ID, 'profilepicture', true );
if ( !$avatar ) {
$avatar = function_exists( 'bp_core_fetch_avatar' ) ? bp_core_fetch_avatar( array( 'item_id' => $user->ID, 'html' => false ) ) : "//gravatar.com/avatar/" . md5( $user->user_email );
}
$avatar = apply_filters( 'muut_fedid_user_avatar_url', $avatar, $user->ID, $user );
$data = array(
'user' => array(
'id' => $user->user_login,
'email' => $user->user_email,
'avatar' => $avatar,
'displayname' => $display_name,
'is_admin' => is_super_admin()
)
);
}
// END FED ID CODE
$message = base64_encode(json_encode($data));
$timestamp = time();
$signature = sha1('SECRET_KEY' . ' ' . $message . ' ' . $timestamp);
?>
<div id="main-content" class="main-content">
<div id="primary" class="content-area">
<article class="page hentry">
<div id="content" class="entry-content" role="main">
<?php if ( apply_filters( 'muut_show_title_on_forum_page', false ) ) { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } ?>
<?php
if ( class_exists( 'Muut' ) ) { ?>
<div id="muut-second-forum" class="muut-second-forum" data-url="/i/FORUMNAME">
<!-- Muut API -->
<a class="muut-url" href="/i/FORUMNAME"><?php echo get_the_title(); ?></a>
<!-- Custom HTML -->
<!-- CUSTOM NAVIGATION -->
</div>
<?php } ?>
</div><!-- #content -->
</article>
</div><!-- #primary -->
</div><!-- #main-content -->
<script>
jQuery(document).ready( function($) {
$('#muut-second-forum').muut({
// Uncomment the next time if you want to show the login link and have it load when clicking to reply
// login_url: '<?php echo apply_filters( 'muut_sso_login_url', wp_login_url( get_permalink() ) ); ?>',
api: {
// API key for "paulhughes"- community
key: 'API_KEY',
// generate following on the server side (see below)
message: '<?php echo $message; ?>',
signature: '<?php echo $signature; ?>',
timestamp: <?php echo $timestamp; ?>
}
})
});
</script>
<?php
if ( apply_filters( 'muut_forum_template_use_primary_theme_sidebar', true ) ) {
get_sidebar();
}
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment