Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KaineLabs/e7e28e4a860665054a15b7fe3309e84e to your computer and use it in GitHub Desktop.
Save KaineLabs/e7e28e4a860665054a15b7fe3309e84e to your computer and use it in GitHub Desktop.
BuddyPres - Youzify Add Buttons for non-logged-in users
<?php
/**
* BuddyPres - Youzify Add Buttons for non-logged-in users
*/
function youify_add_buttons_for_nonloggedin_users() {
if ( is_user_logged_in() || ! function_exists( 'youzify_get_login_page_url' ) ) {
return false;
}
add_action( 'youzify_profile_navbar_right_area', 'yzd_profile_navbar_right_area' );
add_action( 'youzify_wall_embed_user_actions', 'yzd_wall_embed_user_actions' );
add_action( 'youzify_wall_embed_group_actions', 'yzd_wall_embed_group_actions' );
add_action( 'youzify_after_directory_members_actions', 'yzd_members_directory_actions_buttons' );
add_action( 'youzify_after_bp_directory_groups_actions', 'yzd_groups_directory_actions_buttons' );
}
add_action( 'bp_init', 'youify_add_buttons_for_nonloggedin_users' );
/**
* Add Friendship + Message Buttons in non logged-in view
*/
function yzd_profile_navbar_right_area() {
?>
<div id="item-header" class="youzify-social-buttons">
<div class="friendship-button not_friends generic-button"><a href="<?php echo youzify_get_login_page_url(); ?>" class="friendship-button not_friends add"rel="add">Add Friend</a></div>
<div class="youzify-follow-message-button">
<div class="follow-button not-following generic-button"><a href="<?php echo youzify_get_login_page_url(); ?>" class="follow" ">Follow</a></div><div class="message-button generic-button"><a href="<?php echo youzify_get_login_page_url(); ?>" class="youzify-send-message" title="Send a private message to this user."><span>Message</span></a></div>
</div>
</div>
<?php
}
/**
* Add Friendship + Message Buttons in Embed User Post
*/
function yzd_wall_embed_user_actions() {
?>
<div class="friendship-button not_friends generic-button">
<a href="<?php echo youzify_get_login_page_url(); ?>" class="friendship-button not_friends add" rel="add"><?php _e( 'Add Friend', 'youzify' ); ?></a>
</div>
<div class="message-button generic-button">
<a href="<?php echo youzify_get_login_page_url(); ?>" class="yz-send-message" title="Send a private message to this user."><?php _e( 'Message', 'youzify' ); ?></a>
</div>
<?php
}
/**
* Add Join Group in Embed Group Post
*/
function yzd_wall_embed_group_actions() {
?>
<div class="group-button public generic-button">
<a id="group-1" class="group-button join-group" rel="join" href="<?php echo youzify_get_login_page_url(); ?>"><?php _e( 'Join Group', 'youzify' ); ?></a>
</div>
<?php
}
/**
* Members Directory Actions Buttons
*/
function yzd_members_directory_actions_buttons() {
?>
<div class="youzify-user-actions">
<div class="friendship-button not_friends generic-button">
<a href="<?php echo youzify_get_login_page_url(); ?>" class="friendship-button not_friends add" rel="add"><?php _e( 'Add Friend', 'youzify' ); ?></a>
</div>
<div class="message-button generic-button">
<a href="<?php echo youzify_get_login_page_url(); ?>" class="yz-send-message" title="Send a private message to this user."><?php _e( 'Message', 'youzify' ); ?></a>
</div>
</div>
<?php
}
/**
* Groups Directory Actions Buttons
*/
function yzd_groups_directory_actions_buttons() {
?>
<div class="action">
<div class="group-button public generic-button">
<a class="group-button join-group" rel="join" href="<?php echo youzify_get_login_page_url(); ?>"><?php _e( 'Join Group', 'youzify' ); ?></a>
</div>
</div>
<?php
}
/**
* Disable Buttons and Redirect to login page.
*/
function yzc_add_custom_js_code() {
if ( is_user_logged_in() ) {
return;
}
?>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
jQuery( '.friendship-button a,.follow-button a,.group-button a' ).click( function( e ) {
e.stopImmediatePropagation();
});
});
</script>
<?php
}
add_action( 'wp_head' , 'yzc_add_custom_js_code', 999 );
@pmihango
Copy link

How do I add this code to my WordPress website?

@scooller
Copy link

How do I add this code to my WordPress website?

in functions.php in you theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment