Skip to content

Instantly share code, notes, and snippets.

@scottopolis
Created November 9, 2015 18:37
Show Gist options
  • Save scottopolis/452672f856c172d12a16 to your computer and use it in GitHub Desktop.
Save scottopolis/452672f856c172d12a16 to your computer and use it in GitHub Desktop.
AppBuddy use login modal
<?php
/*
* Show login button in toolbar if user not logged in. AppBuddy only
* Put this code in a child theme functions.php file
*/
function my_appbuddy_modal_btn( $button ) {
$args = '';
if ( is_user_logged_in() && bp_is_current_component('activity') || is_user_logged_in() && bp_is_group_home() ) {
$args = array(
'button_class' => 'nav-right-btn io-modal-open',
'icon_class' => 'fa fa-lg fa-edit',
'button_text' => '',
'url' => '#activity-post-form'
);
} else if ( !is_user_logged_in() ) {
$args = array(
'button_class' => 'nav-right-btn login',
'icon_class' => 'fa fa-lg fa-sign-in',
'button_text' => '',
'post_in' => '',
'url' => '#loginModal'
);
}
if( isset($args['url'] ) ) {
$button = sprintf( '<a class="%s io-modal-open" href="%s" data-post="%s"><i class="%s"></i> %s</a>', $args['button_class'], $args['url'], $args['post_in'], $args['icon_class'], $args['button_text'] );
}
return $button;
}
add_filter('appbuddy_modal_button', 'my_appbuddy_modal_btn' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment