{"id":639625,"date":"2007-10-19T00:18:59","date_gmt":"2007-10-19T00:18:59","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/page-generation-plugin\/"},"modified":"2016-08-18T23:42:38","modified_gmt":"2016-08-18T23:42:38","slug":"page-generation-plugin","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/page-generation-plugin\/","title":{"rendered":"Page Generation Plugin"},"content":{"rendered":"<p>Im working on a plugin for my site that will create a pair of pages the first time a user logs in with the user&#8217;s login name as the title of the pages, and then when they log in after the first time check their login name against the list of created pages.<\/p>\n<p>i have <em>most<\/em> of the functionaity working. On login, the pages are created, but the titles are not correct. however, even though the titles are not correct the plugin somehow is able to tell if the pages have been created yet.<\/p>\n<p>is there some kind of bug where the variables are invisible for some reason? unfortunately my site is fairly private so  i cant show you exactly what happens, but the title simply appears blank<\/p>\n<pre><code>&lt;?php\n\/*\nPlugin Name: Brofiles\nPlugin URI: http:\/\/www.xichipsi.com\nDescription: creates a public and private profile page for each user. requires the &quot;Page View&quot; plugin by John Godley\n\nVersion: 0.5\nAuthor: Max &quot;Magnum&quot; Rafferty\nAuthor URI:\n*\/\n?&gt;\n\n&lt;?php\n\nfunction brofile_page_exists()   \/*returns true if the profile page has already been created*\/\n{\n   $the_user = wp_get_current_user();\n   $the_user_login =  $the_user-&gt;user_login;\n   $site_ids = get_all_page_ids();\n\n   for($i=0;$i&lt;sizeof($site_ids);$i++)              \/*for every page*\/\n   {\n   \t\t$the_post=get_post($site_ids[$i]);\n\t\t$the_post_title = $the_post-&gt;post_title;\n                 \/*check if the title matches the username*\/\n   \t\tif(((string)$the_post_title) == ((string)$the_user_login))\n                  {return true;}\n\t}\nreturn false;\n\n}\n\nfunction brofile_create()\n{\n   $the_user = wp_get_current_user();\n   $the_user_login = $the_user-&gt;user_login;\n\n   if(brofile_page_exists())\n   {\n   \t  return;\n\n   }\n    else\n    {\n\t\t\t\/\/Begin Parent Page\n$parent_post_content = &quot;&lt;!-- pageview http:\/\/xichipsi.com\/personal_&quot;.($the_user_login).&quot; contact description --&gt;&quot;;\n$Title = ($the_user_login).&quot; &quot;;\nwp_insert_post(array(\n&#039;post_author&#039;\t\t=&gt; $authorid,\n&#039;post_date&#039;\t\t=&gt; $post_dt,\n&#039;post_date_gmt&#039;\t\t=&gt; $post_dt,\n&#039;post_modified&#039;\t\t=&gt; $post_modified_gmt,\n&#039;post_modified_gmt&#039;\t=&gt; $post_modified_gmt,\n&#039;post_title&#039;\t\t=&gt; $Title,\n&#039;post_content&#039;\t\t=&gt; $parent_post_content,\n&#039;post_excerpt&#039;\t\t=&gt; $post_excerpt,\n&#039;post_status&#039;\t\t=&gt; &#039;publish&#039;,\n&#039;post_name&#039;\t\t=&gt; $post_titre_url,\n&#039;post_type&#039; =&gt; &#039;page&#039;,\n&#039;comment_status&#039;\t=&gt; $comment_status_map[$post_open_comment],\n&#039;ping_status&#039;\t\t=&gt; $comment_status_map[$post_open_tb],\n&#039;comment_count&#039;\t\t=&gt; $post_nb_comment + $post_nb_trackback)\n);\n\/\/End Parent Page\n\n\/\/Begin Profile sub Page\n\t\t$sub_post_content = &quot;Name: \\n Brothername: \\n &quot;;\n\t\t$sub_post_title = &quot;personal_&quot;.($the_user_login).&quot; &quot;;\nwp_insert_post(array(\n&#039;post_author&#039;\t\t=&gt; $authorid,\n&#039;post_date&#039;\t\t=&gt; $post_dt,\n&#039;post_date_gmt&#039;\t\t=&gt; $post_dt,\n&#039;post_modified&#039;\t\t=&gt; $post_modified_gmt,\n&#039;post_modified_gmt&#039;\t=&gt; $post_modified_gmt,\n&#039;post_title&#039;\t\t=&gt; $sub_post_title,\n&#039;post_content&#039;\t\t=&gt; $sub_post_content,\n&#039;post_excerpt&#039;\t\t=&gt; $post_excerpt,\n&#039;post_status&#039;\t\t=&gt; &#039;private&#039;,\n&#039;post_name&#039;\t\t=&gt; $post_titre_url,\n&#039;post_type&#039; =&gt; &#039;page&#039;,\n&#039;comment_status&#039;\t=&gt; $comment_status_map[$post_open_comment],\n&#039;ping_status&#039;\t\t=&gt; $comment_status_map[$post_open_tb],\n&#039;comment_count&#039;\t\t=&gt; $post_nb_comment + $post_nb_trackback)\n);\n\/\/End profile subpage\n\n    }\n   return;\n}\n\nadd_action ( &#039;wp_login&#039;, &#039;brofile_create&#039; );\n\n?&gt;<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-639625","topic","type-topic","status-closed","hentry","topic-tag-page","topic-tag-strings"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/639625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/639625\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=639625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}