Automated Creation of a Page+Post+Category+Tag
-
Hi folks,
I promise there is a question at the end of this!
I’m developing a site where at the moment there are a number of manual steps for a Administrator.
The first is to create a profile page. This page is automatically populated with content by entering a User ID into a custom field and the title is based on an authors first name and last name. The page also needs to be “parented” by the letter that corresponds to the index letter of the user’s first name.
Further manual steps of creating a Category and Tag based on the user’s first and last names are also required.
I had a look at the code below and considered using this as the basis for extending my custom registration Page Template, in order to automatically create a Page, Post, Category and Tag, all based on a user’s first and last names. However, it crossed my mind that not all users will be approved, so I could be creating an automated process that might cause a headache for the Administrator, who then might have to remove any “spammy” Users, along with the associated Pages, Posts, Categories and Tags of any such users.
add_action( 'user_register', 'myplugin_registration_save', 10, 1 ); function myplugin_registration_save( $user_id ) { if ( isset( $_POST['first_name'] ) ) update_user_meta($user_id, 'first_name', $_POST['first_name']); // Code to create page, post, category and tag based on first and last name }
From: https://developer.www.ads-software.com/reference/hooks/user_register/
So my question what is the most “portable” way to trigger the creation of Pages, a single Post, Category and Tag once a user is Verified? By “portable” I mean, I don’t want to modify the core in a way that means I lose my changes when WordPress or a Theme updates, or if it is necessary to do so than minimal rework would be required to get those changes back in?
Thanks,
- The topic ‘Automated Creation of a Page+Post+Category+Tag’ is closed to new replies.