Hasi Weragala
Forum Replies Created
-
Forum: Plugins
In reply to: [Redirection] Performance@johnny5 Thank you Jhon sir. Glad to hear that.
Forum: Plugins
In reply to: [Nextend Social Login and Register] UM Welcome Email for new registrationsThank you sir, It worked well. Appreciate the prompt response.
thank you Veronica. Appreciate it!
Hi Vernoica
I have the same question. But is there any way to do this without plugin? I tried to do with the_content filter but didn’t work.
Best Regards
Hi Veronica
Many thanks for the quick response. Appreciate it. You have a good day now.
Best Regards
Forum: Plugins
In reply to: [Nextend Social Login and Register] The passwordHi Robert
We’ve a use case where visitors who logged in using the traditional method and later connect with their social account. So we need to identify users like that. Is there a way to do that. ?
Because by simply checking for not null provider is not enough in this case.
Awaiting a favorable response.
Best Regards
Hi Veronica
Problem got solved, it was a stray <div> from the comments custom tab.
Hi Veronica
Sorry for the late response. No there are no any errors logged in the console as well
Hi, There are no errors logged in the debug.log.
The last two tabs are supposed to be inside div.um-account-main but apparently they are outside of it.
- This reply was modified 1 month, 1 week ago by Hasi Weragala.
Hi, but why isn’t it closed? have i done anything wrong in my code?
Here is the complete code , when i run it through the html validator it shows these errors. It shows an unclosed form element but i have not used any form therein the code. Please help
https://validator.w3.org/nu/#l68c22889
Here is the site : https://bit.ly/3Yb7q6H
<?php
// Requires for user deletion process
require_once( ABSPATH.'wp-admin/includes/user.php' );
// Init ajax handlers
add_action( 'wp_ajax_nxl_delete_acct', 'nxl_delete_acct' );
add_action( 'wp_ajax_nopriv_nxl_delete_acct', 'nxl_delete_acct' );
function nxl_user_logged_using_socials(){
global $wpdb;
//get the user id
$user_id;
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
} else {
return false;
}
$provider = $wpdb->get_results("SELECT type FROM {$wpdb->prefix}social_users WHERE ID=".$user_id, OBJECT);
if(empty($provider) || is_null($provider)){
return false;
}
else{
return true;
}
if ( $wpdb->last_error ) {
error_log('wpdb error: ' . $wpdb->last_error);
}
}
/* add new tab called "nxltab" */
add_filter('um_account_page_default_tabs_hook', 'nxl_tab_in_um', 100 );
function nxl_tab_in_um( $tabs ) {
/* Add Comments tab */
$tabs[900][ 'comments_tab' ] = array(
'icon' => 'um-faicon-plus',
'title' => __( 'Comments', 'ultimate-member' ),
'custom' => true,
'show_button' => false
);
/* Add Logout tab */
$tabs[1000][ 'nxltab' ] = array(
'icon' => 'um-icon-log-out',
'title' => __( 'Logout', 'ultimate-member' ),
'custom' => true,
'show_button' => false
);
/* Check if the current user has logged in using a social provider */
$is_social_login = nxl_user_logged_using_socials();
if($is_social_login){
/* If it is a social login, hide the password change tab*/
unset($tabs[200]);
/* Further, hide the default account deletion form and load the nxl account deletion form */
unset($tabs[99999]);
$tabs[99999][ 'nxl_delete' ] = array(
'icon' => 'um-faicon-trash-o',
'title' => __( 'Delete Account', 'ultimate-member' ),
'custom' => true,
'show_button' => false
);
}
return $tabs;
}
/* make our new tab hookable */
add_action('um_account_tab__nxltab', 'um_account_tab__nxltab');
function um_account_tab__nxltab( $info ) {
global $ultimatemember;
extract( $info );
$output = $ultimatemember->account->get_tab_output('nxltab');
if ( $output ) { echo $output; }
}
add_action('um_account_tab__nxl_delete', 'um_account_tab__nxl_delete');
function um_account_tab__nxl_delete( $info ) {
global $ultimatemember;
extract( $info );
$output = $ultimatemember->account->get_tab_output('nxl_delete');
if ( $output ) { echo $output; }
}
add_action('um_account_tab__comments_tab', 'um_account_tab__comments_tab');
function um_account_tab__comments_tab( $info ) {
global $ultimatemember;
extract( $info );
$output = $ultimatemember->account->get_tab_output('comments_tab');
if ( $output ) { echo $output; }
}
/* Finally we add some content in the tabs */
add_filter('um_account_content_hook_nxltab', 'um_account_content_hook_nxltab', 20);
function um_account_content_hook_nxltab( $output = ''){
$logout_url = wp_logout_url(home_url());
ob_start();
?>
<div class="um-field um-left">
<p>Are you sure you want to logout?</p>
<a class="um-button nxl_fit_content" href="<?php echo $logout_url; ?>">Logout</a>
</div>
<?php
$output .= ob_get_contents();
ob_end_clean();
return $output;
}
add_filter('um_account_content_hook_nxl_delete', 'um_account_content_hook_nxl_delete', 20);
function um_account_content_hook_nxl_delete( $output = ''){
ob_start();
?>
<p>Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account enter your email address below.</p>
<div id="um_field_0_single_user_email" class="um-field um-field-email um-field-single_user_email um-field-email um-field-type_email" data-key="single_user_email">
<div class="um-field-label">
<label for="single_user_email">Email<span class="um-req" title="Required">*</span></label>
</div>
<div class="um-field-area">
<input class="um-form-field valid" type="email" name="single_user_email" id="single_user_email" value="" placeholder="" data-validate="" data-key="single_user_email" aria-invalid="false">
</div>
</div>
<div class="um-col-alt">
<button class="um-button nxl_fit_content" id="nxl_delete_acct" type="submit">Delete Account</button>
</div>
<div class="nxl_notifications_wrapper">
<span id="nxl_notifications"></span>
</div>
<?php
$output .= ob_get_contents();
ob_end_clean();
return $output;
}
/**
* Add custom tab content.
*
* @param string $output Tab content.
* @return string
*/
function um_account_content_comments_tab( $output = '' ) {
$user_id = get_current_user_id();
// get comments data structure
$comments = get_comments( array(
'number' => 10,
'user_id' => $user_id,
'post_status' => array('publish')
) );
if ( ! empty( $comments ) ) {
$output .= '<div class="um-ajax-items">';
foreach ( $comments as $comment ) {
$comment_title = apply_filters( 'um_user_profile_comment_title', get_the_title( $comment->comment_post_ID ), $comment );
$link = apply_filters( 'um_user_profile_comment_url', get_permalink( $comment->comment_post_ID ), $comment );
$output .= '<div class="um-item">
<div class="um-item-link">
<i class="um-icon-chatboxes"></i>
<a href="'.esc_url( get_comment_link( $comment->comment_ID ) ).'">
'.get_comment_excerpt( $comment->comment_ID ).'
</a>
</div>
<div class="um-item-meta">
<span>'.
'On <a href="'.$link.'">'.$comment_title.'</a>'
.'</span>
</div>
</div>';
}
if ( $count_comments > 10 ) {
$output .= '<div class="um-load-items"><a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_comments"
data-user_id="'.esc_attr( um_get_requested_user() ).'" data-page="1"
data-pages="'.esc_attr( ceil( $count_comments / 10 ) ).'">'.
_e( 'load more comments', 'ultimate-member' ).'
</a>
</div>';
}
} else {
$output .= '<div class="um-profile-note"><span>You have not made any comments</span></div>';
}
$output .= '</div>';
return $output;
}
add_filter( 'um_account_content_hook_comments_tab', 'um_account_content_comments_tab', 20 );- This reply was modified 1 month, 1 week ago by Hasi Weragala.
Hi Veronica
I have added some custom tabs to the site but tab heading styles are not applied for non-admin users. Is there a setting that I’ve missed? Please help
- This reply was modified 1 month, 1 week ago by Hasi Weragala.
Thanks so much Veronica. ? need one more help from you
I want to modify the delete account form a bit. I want to remove password field therein and replace it with an email field. Is that possible?
Thank you veronica for the swift response. appreciate it.
In the code you provided it doesn’t display any fields . how to render the fields ?
Thanks so much veronica. The tab shows up but doesn’t render any fields.
may I also know what is that index in $tabs array signifies? e:g 999 in $tab[999]
further, is it possible to add the comments profile tab as a accounts tab?
- This reply was modified 1 month, 1 week ago by Hasi Weragala.
- This reply was modified 1 month, 1 week ago by Hasi Weragala.