• Resolved shemakeswebsites

    (@shemakeswebsites)


    Hello, is there a way to display a last login data in the admin dashboard for my users with your plugin? Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support alexandrubodea

    (@alexandrubodea)

    Hi @shemakeswebsites,

    Yes, this is possible.

    1. Go to your Dashboard -> Profile Builder -> Settings -> Advanced settings -> and enable Save ‘Last Login’ date in usermeta

    2. To create a new column in your Dashboard -> Users -> All Users page, and to display the last login date you will have to use the following custom code:

    //Modify Users Table
    function wppbc_users_table_columns( $column ) {
    	$column['last_login_date'] = 'Last Login';
    
    	return $column;
    }
    add_filter( 'manage_users_columns', 'wppbc_users_table_columns' );
    
    //Add column value
    function wppbc_users_table_row( $val, $column_name, $user_id ) {
    	switch ($column_name) {
    		case 'last_login_date' :
    			return get_user_meta($user_id, 'last_login_date', true);
    			break;
    		default:
    		}
    	return $val;
    	}
    add_filter( 'manage_users_custom_column', 'wppbc_users_table_row', 10, 3 );

    You can replace ‘Last Login’ with what name you want your column to have.

    Note: You can use this code by adding it to your theme’s ‘functions.php’ file or by creating a new plugin as described here.

    As with all modifications, please do a backup of your site before moving forward with it.

    Best regards,

    Thread Starter shemakeswebsites

    (@shemakeswebsites)

    Thank you but that doesn’t seem to work. The new column appears, but the data that is shown in the column is just the users ID. No date info.

    Thoughts?

    Plugin Support alexandrubodea

    (@alexandrubodea)

    Hi @shemakeswebsites,

    1. Could you please go to your Dashboard -> Profile Builder -> Settings -> Advanced settings -> Forms -> scroll to the bottom of the page where the “Save ‘Last Login’ date in usermeta” settings can be seen -> and send a full screenshot from there?

    2. Could you please go to your Dashboard -> Users -> All Users -> and send a full screenshot from there where the new column can be seen?
    ?
    Note: ?You can use a site like https://snipboard.io/ to share the screenshots.

    Best regards,

    Thread Starter shemakeswebsites

    (@shemakeswebsites)

    Sorry this isn’t resolved. I got busy and forgot about my ticket.

    Here is the settings: https://snipboard.io/5WgoAr.jpg

    Here are the users: https://snipboard.io/4fFlmp.jpg

    Thank you!

    Plugin Support alexandrubodea

    (@alexandrubodea)

    Hi @shemakeswebsites,

    Could you please change the last line from the custom code I sent you (the code from 2 months ago) with this one:

    add_filter( 'manage_users_custom_column', 'wppbc_users_table_row', 40, 3 );

    So the code will look like this now:

    //Modify Users Table
    function wppbc_users_table_columns( $column ) {
    	$column['last_login_date'] = 'Last Login';
    
    	return $column;
    }
    add_filter( 'manage_users_columns', 'wppbc_users_table_columns' );
    
    //Add column value
    function wppbc_users_table_row( $val, $column_name, $user_id ) {
    	switch ($column_name) {
    		case 'last_login_date' :
    			return get_user_meta($user_id, 'last_login_date', true);
    			break;
    		default:
    		}
    	return $val;
    	}
    add_filter( 'manage_users_custom_column', 'wppbc_users_table_row', 40, 3 );

    As with all modifications, please do a backup of your site before moving forward with it.

    Do you still encounter this issue after making the above modifications?

    Best regards,

    Thread Starter shemakeswebsites

    (@shemakeswebsites)

    Perfect! That worked – thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Last login’ is closed to new replies.