{"id":41770,"date":"2024-11-30T19:06:54","date_gmt":"2024-11-30T17:06:54","guid":{"rendered":"https:\/\/coma.lv\/2024\/11\/30\/how-to-display-the-registration-date-in-wordpress\/"},"modified":"2024-11-30T19:06:54","modified_gmt":"2024-11-30T17:06:54","slug":"how-to-display-the-registration-date-in-wordpress","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2024\/11\/30\/how-to-display-the-registration-date-in-wordpress\/","title":{"rendered":"How to Display the Registration Date in WordPress"},"content":{"rendered":"\n<p style=\"text-align: left;\">Popular membership sites and forums often display the registration date in their users&#8217; profiles. For example: member since 2015. In this article we will explain how you can do this.<\/p>\n<h2 style=\"text-align: left;\">When and Why You Might Need to Display the Registration Date<\/h2>\n<p style=\"text-align: left;\">Displaying the registration date in the admin panel lets you sort users by registration date. Another scenario is displaying the registration date on the profile page, which lets you see when a user was registered. The last option is when the registration date is publicly visible. Let&#8217;s look at each of these scenarios.<\/p>\n<h2 style=\"text-align: left;\">Adding a User Registration Date Column in the Admin<\/h2>\n<p style=\"text-align: left;\">First you need to install and activate the Admin Columns plugin. After activation, go to Settings &gt; Admin Columns to configure the plugin.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/11\/addregisteredcolumn.jpg\" alt=\"WordPress\" title=\"\"><\/p>\n<p style=\"text-align: left;\">Under the columns tab, click users and then click the add column button. Then choose Registered in the drop-down menu and click store updates. Now you can go to the users screen and you will see a Registered column there, showing the users&#8217; registration dates.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/11\/userstable.jpg\" alt=\"WordPress\" title=\"\"><\/p>\n<h2 style=\"text-align: left;\">Displaying the Registration Date in a User Profile<\/h2>\n<p style=\"text-align: left;\">To show the registration date in the profile settings, you need to upload a custom plugin. Just create a new file using a text editor such as Notepad and name it membersince.php. Then paste the following code into it:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;?php\r\n\r\n\r\nnamespace ShowMemberSince;\r\nadd_action( &amp;#039;plugins_loaded&amp;#039;, &amp;#039;ShowMemberSince\\init&amp;#039; );\r\n\/**\r\n * Adding needed action hooks\r\n*\/\r\nfunction init(){\r\n  foreach( array( &amp;#039;show_user_profile&amp;#039;, &amp;#039;edit_user_profile&amp;#039; ) as $hook )\r\n\t\tadd_action( $hook, &amp;#039;ShowMemberSince\\add_custom_user_profile_fields&amp;#039;, 10, 1 );\r\n}\r\n\/**\r\n * Output table\r\n * @param object $user User object\r\n *\/\r\nfunction add_custom_user_profile_fields( $user ){\r\n\t$table =\r\n\t&amp;#039;\r\n&amp;lt;h3&amp;gt;%1$s&amp;lt;\/h3&amp;gt;\r\n\r\n\r\n&amp;lt;table class=&amp;quot;form-table&amp;quot;&amp;gt;\r\n\r\n&amp;lt;tr&amp;gt;\r\n\r\n&amp;lt;th&amp;gt;\r\n\t\t\t\t%1$s\r\n\t\t\t&amp;lt;\/th&amp;gt;\r\n\r\n\r\n&amp;lt;td&amp;gt;\r\n\r\n\r\nMember since: %2$s\r\n\r\n\t\t\t&amp;lt;\/td&amp;gt;\r\n\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\r\n\t&amp;lt;\/table&amp;gt;\r\n\r\n&amp;#039;;\r\n\t$udata = get_userdata( $user-ID );\r\n\t$registered = $udata-&amp;gt;user_registered;\r\n\tprintf(\r\n\t\t$table,\r\n\t\t&amp;#039;Registered&amp;#039;,\r\n\t\tdate( &amp;quot;M Y&amp;quot;, strtotime( $registered ) )\r\n\t);\r\n}\r\n?&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\">Save the file and upload it to your WordPress site. You can connect to your site with an FTP client and go to the wp-content\/plugins\/ folder. Now you can go to the plugins page and activate your new plugin. That&#8217;s all. Check that the plugin works by simply opening the profile edit screen in your admin, and you will see the user&#8217;s registration date.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/11\/membersince.jpg\" alt=\"WordPress\" title=\"\"><\/p>\n<h2 style=\"text-align: left;\">Displaying a User&#8217;s Registration Date on Your Site<\/h2>\n<p style=\"text-align: left;\">In this method we will use a simple shortcode to display users&#8217; registration dates on your site. First you need to add the following code to the functions.php file<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction wpb_user_registration_date($atts, $content = null ) { \r\n\r\n$userlogin = shortcode_atts( array(\r\n&amp;#039;user&amp;#039; =&amp;gt; FALSE,\r\n), $atts );\r\n\r\n$uname = $userlogin&#x5B;&amp;#039;user&amp;#039;];     \r\n\r\nif ($uname!== FALSE) {             \r\n\r\n$user = get_user_by( &amp;#039;login&amp;#039;, $uname );  \r\nif ($user == false) { \r\n\r\n$message =&amp;#039;Sorry no such user found.&amp;#039;; \r\n\r\n\r\n} else { \r\n\r\n$udata = get_userdata( $user-ID );\r\n$registered = $udata-&amp;gt;user_registered;\r\n\r\n$message =\t&amp;#039;Member since: &amp;#039; . date( &amp;quot;d F Y&amp;quot;, strtotime( $registered ) );\r\n\r\n}\r\n\t\r\n} else { \r\n\r\n$message = &amp;#039;Please provide a username.&amp;#039;; \r\n\r\n} \r\n\r\nreturn $message; \r\n\r\n} \r\n\r\nadd_shortcode(&amp;#039;membersince&amp;#039;, &amp;#039;wpb_user_registration_date&amp;#039;);\r\n<\/pre>\n<p style=\"text-align: left;\">Then you can display a user&#8217;s registration date simply by using a shortcode like this:<\/p>\n<p style=\"text-align: left;\">[membersince user=peter]<\/p>\n<p style=\"text-align: left;\">Just replace peter with the username of the user whose registration date you are going to display.<\/p>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>Popular membership sites and forums often display the registration date in their users&#8217; profiles. For example: member since 2015. In this article we will explain how you can do this. When and Why You Might Need to Display the Registration Date Displaying the registration date in the admin panel lets you sort users by registration [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38182,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1407],"tags":[],"class_list":["post-41770","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-tutorials"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41770"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41770\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/38182"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}