{"id":274,"date":"2014-11-07T10:37:40","date_gmt":"2014-11-07T10:37:40","guid":{"rendered":"http:\/\/localhost\/syllogic\/wp\/?p=274"},"modified":"2024-02-02T12:22:27","modified_gmt":"2024-02-02T12:22:27","slug":"manage-user-profile-and-credentials","status":"publish","type":"post","link":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/","title":{"rendered":"Manage user profile and credentials"},"content":{"rendered":"\n

We recently required to force our newly registered users on a project to change their password on their first login.  This is handled by default in the WordPress core with the default password nag meta field,<\/p>\n\n\n\n

update_user_option( $user_id, 'default_password_nag', true, true );<\/code><\/pre>\n\n\n\n

However, upon the first login the user is redirected to the wordpress default profile.php<\/code> page which is not very intuitive, does not allow for customisation and more importantly is outside the scope of the template theme.<\/p>\n\n\n\n

Template My Login to the rescue.<\/h3>\n\n\n\n

This is where I found a lovely little plugin, Template My Login (TML)<\/a>, which creates a set of pages with a simple shortcode in each of them. It creates a page for Login, Logout, Profile, Register and so on, allowing for each page to be automatically themed but also customised with a template.<\/p>\n\n\n\n

Putting it all together.<\/h3>\n\n\n\n

Automatic registration of new users with auto-generated passwords can make a call to update the default password nag meta field,<\/p>\n\n\n\n

update_user_option( $user_id, 'default_password_nag', true, true );<\/code><\/pre>\n\n\n\n

This can be called after a registration form, or within your code when you create a new user.
\nWhen a user logs-in for the first time they will be automatically redirected to their profile page.  Upon resetting their password, WordPress will automatically reset the default_password_nag<\/code> meta field to null.<\/p>\n\n\n\n

We can further modify the TML plugin default profile_form.php<\/code> template to show a small message indicating that the user has been redirected to change their password if this is their first login,<\/p>\n\n\n\n

<?php\n\/*\nIf you would like to edit this file, copy it to your current theme's directory and edit it there.\nTheme My Login will always look in your theme's directory first, before using this default template.\n*\/\n$nagPassword = null;\nif ( is_user_logged_in( ) ) {\n   \/\/$user_ID = get_current_user_id();\n   $nagPassword = get_user_option('default_password_nag');\n}\n?>\n<div class=\"login profile\" id=\"theme-my-login<?php $template->the_instance(); ?>\">\n<?php if($nagPassword) { ?>\n    <p class=\"message\">\n        If this is your first log-in, you have been re-directed to your profile setting page in order to reset your password.\n        &nbsp;\n        Please choose a new password below\n    <\/p>\n<?php } ?>\n    <?php $template->the_action_template_message( 'profile' ); ?>\n    <?php $template->the_errors(); ?>\n    <form id=\"your-profile\" ....<\/code><\/pre>\n\n\n\n

The TML templates sit in the plugin folder, plugins\/theme-my-login\/templates <\/code>just copy the relevant template to your theme folder and TML will first look there for the template file.  Easy as pie!<\/p>\n","protected":false},"excerpt":{"rendered":"

We recently required to force our newly registered users on a project to change their password on their first login.  This is handled by default in the WordPress core with the default password nag meta field, However, upon the first login the user is redirected to the wordpress default profile.php page which is not very […]<\/p>\n","protected":false},"author":2,"featured_media":331,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"yoast_head":"\nManage user profile and credentials - Tiffin Consulting<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Manage user profile and credentials - Tiffin Consulting\" \/>\n<meta property=\"og:description\" content=\"We recently required to force our newly registered users on a project to change their password on their first login.  This is handled by default in the WordPress core with the default password nag meta field, However, upon the first login the user is redirected to the wordpress default profile.php page which is not very […]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\" \/>\n<meta property=\"og:site_name\" content=\"Tiffin Consulting\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-07T10:37:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-02T12:22:27+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/localhost:10008\/wp-content\/uploads\/2014\/11\/login.png\" \/>\n\t<meta property=\"og:image:width\" content=\"741\" \/>\n\t<meta property=\"og:image:height\" content=\"576\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Aurovrata V.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aurovrata V.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t \"@context\": \"https:\/\/schema.org\",\n\t \"@graph\": [\n\t {\n\t \"@type\": \"Article\",\n\t \"@id\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/#article\",\n\t \"isPartOf\": {\n\t \"@id\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\"\n\t },\n\t \"author\": {\n\t \"name\": \"Aurovrata V.\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99\"\n\t },\n\t \"headline\": \"Manage user profile and credentials\",\n\t \"datePublished\": \"2014-11-07T10:37:40+00:00\",\n\t \"dateModified\": \"2024-02-02T12:22:27+00:00\",\n\t \"mainEntityOfPage\": {\n\t \"@id\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\"\n\t },\n\t \"wordCount\": 271,\n\t \"publisher\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6\"\n\t },\n\t \"articleSection\": [\n\t \"Plugin Reviews\"\n\t ],\n\t \"inLanguage\": \"en-US\"\n\t },\n\t {\n\t \"@type\": \"WebPage\",\n\t \"@id\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\",\n\t \"url\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\",\n\t \"name\": \"Manage user profile and credentials - Tiffin Consulting\",\n\t \"isPartOf\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#website\"\n\t },\n\t \"datePublished\": \"2014-11-07T10:37:40+00:00\",\n\t \"dateModified\": \"2024-02-02T12:22:27+00:00\",\n\t \"breadcrumb\": {\n\t \"@id\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/#breadcrumb\"\n\t },\n\t \"inLanguage\": \"en-US\",\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"ReadAction\",\n\t \"target\": [\n\t \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/\"\n\t ]\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"BreadcrumbList\",\n\t \"@id\": \"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/#breadcrumb\",\n\t \"itemListElement\": [\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 1,\n\t \"name\": \"Home\",\n\t \"item\": \"http:\/\/localhost:10008\/\"\n\t },\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 2,\n\t \"name\": \"Manage user profile and credentials\"\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"WebSite\",\n\t \"@id\": \"http:\/\/localhost:10008\/#website\",\n\t \"url\": \"http:\/\/localhost:10008\/\",\n\t \"name\": \"Tiffin Consulting\",\n\t \"description\": \"digital business transformation\",\n\t \"publisher\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6\"\n\t },\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"SearchAction\",\n\t \"target\": {\n\t \"@type\": \"EntryPoint\",\n\t \"urlTemplate\": \"http:\/\/localhost:10008\/?s={search_term_string}\"\n\t },\n\t \"query-input\": \"required name=search_term_string\"\n\t }\n\t ],\n\t \"inLanguage\": \"en-US\"\n\t },\n\t {\n\t \"@type\": [\n\t \"Person\",\n\t \"Organization\"\n\t ],\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6\",\n\t \"name\": \"Aurovrata V.\",\n\t \"image\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"en-US\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/image\/\",\n\t \"url\": \"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png\",\n\t \"contentUrl\": \"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png\",\n\t \"width\": 1060,\n\t \"height\": 644,\n\t \"caption\": \"Aurovrata V.\"\n\t },\n\t \"logo\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/image\/\"\n\t },\n\t \"sameAs\": [\n\t \"http:\/\/localhost:10008\"\n\t ]\n\t },\n\t {\n\t \"@type\": \"Person\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99\",\n\t \"name\": \"Aurovrata V.\",\n\t \"image\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"en-US\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/image\/\",\n\t \"url\": \"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\n\t \"contentUrl\": \"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\n\t \"caption\": \"Aurovrata V.\"\n\t },\n\t \"url\": \"http:\/\/localhost:10008\/author\/aurovrata\/\"\n\t }\n\t ]\n\t}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Manage user profile and credentials - Tiffin Consulting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/","og_locale":"en_US","og_type":"article","og_title":"Manage user profile and credentials - Tiffin Consulting","og_description":"We recently required to force our newly registered users on a project to change their password on their first login.  This is handled by default in the WordPress core with the default password nag meta field, However, upon the first login the user is redirected to the wordpress default profile.php page which is not very […]","og_url":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/","og_site_name":"Tiffin Consulting","article_published_time":"2014-11-07T10:37:40+00:00","article_modified_time":"2024-02-02T12:22:27+00:00","og_image":[{"width":741,"height":576,"url":"http:\/\/localhost:10008\/wp-content\/uploads\/2014\/11\/login.png","type":"image\/png"}],"author":"Aurovrata V.","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Aurovrata V.","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/#article","isPartOf":{"@id":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/"},"author":{"name":"Aurovrata V.","@id":"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99"},"headline":"Manage user profile and credentials","datePublished":"2014-11-07T10:37:40+00:00","dateModified":"2024-02-02T12:22:27+00:00","mainEntityOfPage":{"@id":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/"},"wordCount":271,"publisher":{"@id":"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6"},"articleSection":["Plugin Reviews"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/","url":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/","name":"Manage user profile and credentials - Tiffin Consulting","isPartOf":{"@id":"http:\/\/localhost:10008\/#website"},"datePublished":"2014-11-07T10:37:40+00:00","dateModified":"2024-02-02T12:22:27+00:00","breadcrumb":{"@id":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/localhost:10008\/manage-user-profile-and-credentials\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/localhost:10008\/manage-user-profile-and-credentials\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/localhost:10008\/"},{"@type":"ListItem","position":2,"name":"Manage user profile and credentials"}]},{"@type":"WebSite","@id":"http:\/\/localhost:10008\/#website","url":"http:\/\/localhost:10008\/","name":"Tiffin Consulting","description":"digital business transformation","publisher":{"@id":"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/localhost:10008\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6","name":"Aurovrata V.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/localhost:10008\/#\/schema\/person\/image\/","url":"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png","contentUrl":"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png","width":1060,"height":644,"caption":"Aurovrata V."},"logo":{"@id":"http:\/\/localhost:10008\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/localhost:10008"]},{"@type":"Person","@id":"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99","name":"Aurovrata V.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/localhost:10008\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"Aurovrata V."},"url":"http:\/\/localhost:10008\/author\/aurovrata\/"}]}},"_links":{"self":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts\/274"}],"collection":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":2,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":332,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts\/274\/revisions\/332"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/media\/331"}],"wp:attachment":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}