WordPress.org

Forums

Auto generate template sub-page with username as title (6 posts)

  1. Avi
    Member
    Posted 2 years ago #

    Hi,
    How do I automatically generate a sub page for every user that registers to my site?
    I want the title of the automatically generated page to be equal to the username of the user and be placed with a certain page template.
    Any help out there?

    here is my website:
    http://www.StarShowsStudios.com

  2. bcworkz
    Member
    Posted 2 years ago #

    Hook into the action 'user_register' and use wp_insert_post(). Even though you are creating a page, the insert post function works, you supply 'page' as the post_type argument. Once you have the page/post ID you specify the template by adding the template filename to postmeta under the key '_wp_page_template'.

  3. garypenn
    Member
    Posted 1 year ago #

    tell me more about how you get the above to work.
    same thing i want to create pages for my users with their name for the page to be saved as site name their name.
    would also like to use a responsive theme that i edited or page copy of one i already edited.

  4. bcworkz
    Member
    Posted 1 year ago #

    The method works with any theme and any page template you care to use. See Plugin Hooks for how to hook actions like 'user_register'. See wp_insert_post() for how to use the function itself. Set the template postmeta with update_post_meta().

    You don't even really need a page for each user, a single template could display any user's data by virtue of them being logged in. The main difference is all users access their page with the same permalink instead of a unique permalink, but they all still each see their own content. This is how the standard back end profile page works.

  5. oshi
    Member
    Posted 1 year ago #

    Hi BCworkz am looking into the same thing and i was wondering if there's a plugin for this...

  6. bcworkz
    Member
    Posted 1 year ago #

    Hi oshi, I'm sorry, I'm not the best person to ask. For the most part I try to custom code everything, so I'm not aware of very many plugins. I realize many people cannot code their own solutions for various reasons, so plugin availability is important to them.

    There very well may be a plugin, I just don't know. I suspect you can search as well as I, if not better, so I'll leave you to it. Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic