{"id":4270,"date":"2018-08-08T15:15:33","date_gmt":"2018-08-08T19:15:33","guid":{"rendered":"https:\/\/themespress.ca\/?p=4270"},"modified":"2022-10-01T14:29:15","modified_gmt":"2022-10-01T18:29:15","slug":"adding-user-functions","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/adding-user-functions\/","title":{"rendered":"Adding a User via Functions.php"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>With this tutorial, we will show you how to add a WordPress user via the functions.php file. This how-to is pretty useful in case you can&#8217;t access your admin section of WordPress for whatever reason may be.<\/p>\n<p>While you can always do a password reset, you can easily add a simply line of code within your functions.php file via an FTP software:<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >Adding a WordPress user via functions.php<\/h2><div id=\"ts-enlighterjs-container-5221907\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-5221907\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">function nomdevotrefuonction(){\n  \/\/\/ Ici mettez votre nom utilisateur sans majuscules\n  $user = &#039;Username&#039;;\n  \/\/\/ Ici mettez votre mot de passe\n  $pass = &#039;Password&#039;;\n  \/\/\/ Ici mettez votre courriel\n  $email = &#039;email@domain.com&#039;;\n \n  \/\/\/ Condition que utilisateur existe pas on le cr&eacute;&eacute;\n  if ( !username_exists( $user )  &amp;&amp; !email_exists( $email ) ) {\n  $user_id = wp_create_user( $user, $pass, $email );\n  $user = new WP_User( $user_id );\n  $user-&gt;set_role( &#039;administrator&#039; );\n  } \n}\n \nadd_action(&#039;init&#039;,&#039;nomdevotrefuonction&#039;);<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Once you&#8217;ll save the changes in the functions.php file, the new user will be created thus allowing you to log back in.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"With this tutorial, we will show you how to add a WordPress user via the functions.php file. This how-to is pretty useful in case you can't access your admin section<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/adding-user-functions\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4963,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[],"class_list":["post-4270","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=4270"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4270\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4963"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}