Title: Page Generation Plugin
Last modified: August 18, 2016

---

# Page Generation Plugin

 *  [Magnum](https://wordpress.org/support/users/magnum/)
 * (@magnum)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/page-generation-plugin/)
 * 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’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.
 * i have _most_ 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.
 * 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
 *     ```
       <?php
       /*
       Plugin Name: Brofiles
       Plugin URI: http://www.xichipsi.com
       Description: creates a public and private profile page for each user. requires the "Page View" plugin by John Godley
   
       Version: 0.5
       Author: Max "Magnum" Rafferty
       Author URI:
       */
       ?>
   
       <?php
   
       function brofile_page_exists()   /*returns true if the profile page has already been created*/
       {
          $the_user = wp_get_current_user();
          $the_user_login =  $the_user->user_login;
          $site_ids = get_all_page_ids();
   
          for($i=0;$i<sizeof($site_ids);$i++)              /*for every page*/
          {
          		$the_post=get_post($site_ids[$i]);
       		$the_post_title = $the_post->post_title;
                        /*check if the title matches the username*/
          		if(((string)$the_post_title) == ((string)$the_user_login))
                         {return true;}
       	}
       return false;
   
       }
   
       function brofile_create()
       {
          $the_user = wp_get_current_user();
          $the_user_login = $the_user->user_login;
   
          if(brofile_page_exists())
          {
          	  return;
   
          }
           else
           {
       			//Begin Parent Page
       $parent_post_content = "<!-- pageview http://xichipsi.com/personal_".($the_user_login)." contact description -->";
       $Title = ($the_user_login)." ";
       wp_insert_post(array(
       'post_author'		=> $authorid,
       'post_date'		=> $post_dt,
       'post_date_gmt'		=> $post_dt,
       'post_modified'		=> $post_modified_gmt,
       'post_modified_gmt'	=> $post_modified_gmt,
       'post_title'		=> $Title,
       'post_content'		=> $parent_post_content,
       'post_excerpt'		=> $post_excerpt,
       'post_status'		=> 'publish',
       'post_name'		=> $post_titre_url,
       'post_type' => 'page',
       'comment_status'	=> $comment_status_map[$post_open_comment],
       'ping_status'		=> $comment_status_map[$post_open_tb],
       'comment_count'		=> $post_nb_comment + $post_nb_trackback)
       );
       //End Parent Page
   
       //Begin Profile sub Page
       		$sub_post_content = "Name: \n Brothername: \n ";
       		$sub_post_title = "personal_".($the_user_login)." ";
       wp_insert_post(array(
       'post_author'		=> $authorid,
       'post_date'		=> $post_dt,
       'post_date_gmt'		=> $post_dt,
       'post_modified'		=> $post_modified_gmt,
       'post_modified_gmt'	=> $post_modified_gmt,
       'post_title'		=> $sub_post_title,
       'post_content'		=> $sub_post_content,
       'post_excerpt'		=> $post_excerpt,
       'post_status'		=> 'private',
       'post_name'		=> $post_titre_url,
       'post_type' => 'page',
       'comment_status'	=> $comment_status_map[$post_open_comment],
       'ping_status'		=> $comment_status_map[$post_open_tb],
       'comment_count'		=> $post_nb_comment + $post_nb_trackback)
       );
       //End profile subpage
   
           }
          return;
       }
   
       add_action ( 'wp_login', 'brofile_create' );
   
       ?>
       ```
   

The topic ‘Page Generation Plugin’ is closed to new replies.

## Tags

 * [page](https://wordpress.org/support/topic-tag/page/)
 * [strings](https://wordpress.org/support/topic-tag/strings/)

 * 0 replies
 * 1 participant
 * Last reply from: [Magnum](https://wordpress.org/support/users/magnum/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/page-generation-plugin/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
