Show Last login Time Of User In WordPress

How to display Quickly a WordPress user’s last login with custom code . Actually some time  we need to know our active users of site. so we can differentiate which user hasn’t logged in for a while. This is combination  4-5 hooks. 1: First we can use wp_login hook for saving login time and date. <?php //Record user’s last login to custom meta field add_action( ‘wp_login’, ‘custum_wp_login’, 10, 2 ); function custum_wp_login( $user_login, $user ) { update_user_meta( $user->ID, ‘custum_last_login’, date(‘Y-m-d H:i:s’)); }   2: Second we need to add column in user table to show last login <?php //Register new custom column with last login time add_filter( ‘manage_users_columns’, ‘custum_manage_users_columns’); add_filter(‘manage_users_custom_column’, ‘custum_manage_users_custom_column’, 10, 3); function custum_manage_users_columns( $columns ) { $columns[‘custum_last_login’] = __(‘Last login’, ‘last_login’); return $columns; } function custum_manage_users_custom_column( $value, $column_name, $user_id ) { if ( ‘custum_last_login’ == $column_name){ $last_login = get_user_meta( $user_id, ‘custum_last_login’, true ); $value = date(“g:i a –

Add Custom Product Data Tab

Learn how to enhance your WooCommerce product editor by adding a custom product data tab. Follow a step-by-step guide using the woocommerce_product_data_tabs filter and the woocommerce_product_data_panels action. Create a custom tab with your desired label, and include your own fields or content within the panel. Customize your product data to collect and display additional information, providing a tailored experience for your WooCommerce products.

How To Add Menu In WordPress Admin Panel

How to add menu in WordPress admin panel – In this post we see how we can add custom menu to admin sidebar. Sometimes when we on WordPress and we need to show some features or any information in admin page then we can use this code snippet to create the same.

How To Limit Search To Post Titles?

I added a text field to the posts filter form and I use s= parameter to make the search work. But how to search only in the title of the post (not in the content)? how to limit search to post titles? How to search only by Post Title?

How To Customize/Replace WordPress Post Excerpts

Example: Sometime we need to show content on frontend with adding some prefix or suffix or may be you have enter spelling mistakes in 2000 posts. so it is very difficult to modify 2000 posts so we can modify using filter . SO mistake will be replaced by correction.   For Modifying post content only:   function link_words( $text ) { $replace = ‘Replace with’; $text = str_replace( ‘Want To replace text’, $replace, $text ); return $text; } add_filter( ‘the_content’, ‘link_words’ );   For Modifying post excerpt only   function link_words( $text ) { $replace = ‘Replace with’; $text = str_replace( ‘Want To replace text’, $replace, $text ); return $text; } add_filter( ‘the_excerpt’, ‘link_words’ );   For Modifying post content and excerpt both   function link_words( $text ) { $replace = ‘Replace with’; $text = str_replace( ‘Want To replace text’, $replace, $text ); return $text; } add_filter( ‘the_content’, ‘link_words’ );

Sort A ACF Repeater Field Results

Filters the field $value after being loaded. Sort a repeater field using a function called array_multisort(). Sorting Filtering Modifying ACF results .

Categories

Request A Quote

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.