Guest Author is a kind of guest account in which the visitors can register and use it to submit a post without any admin permission. This helps you have more content for your site, so it absolutely benefits you. From an order of my client, I saw that adding this is pretty interesting then want to share with you how to do it. Of course, using Meta Box.

The order from my client has a form as below:

  1. The guest can register an account and manage it in frontend as a Guest Author account;
  2. Guest Author can submit posts to the website;
  3. Every guest post from Guest Author must be review before publishing;
  4. Guest Author can manage their posts list, edit each one before reviewing.

I will show you how to solve all the above requirements in two posts. In the first one, I’m solving the 1st and 2nd. The left ones are going on in the next post.

Before Get Started

To solve all the above requirements, we should use Meta Box and its three extensions, which are:

Now, let’s get started.

Create My Account page in the frontend

Step 1: Allow guest users to register and login an account

Turning on this function is quite easy. In the admin dashboard, go to the Settings menu > General, then check the box Anyone can register in the Membership item.

Allow guest user to register and login an account
Allow guest users to register an account

In the New User Default Role item, you should choose a Subscriber to restrict the permission of the new user.

Now, go to the default login page of WordPress (URL: yourdomain.com/wp-login), you will see the Register link as in the below image.

the Register link as in the below image

When someone clicks to the text Register, they will be redirected to the register page.

Step 2: Create fields for user profile

In this step, we will use MB User Profile to create fields for the user profile, which can be managed and edited from the frontend.

Firstly, we create a new custom field group (means custom meta box). Go to the Meta Box menu > Custom fields > Add New in the admin dashboard.

Create a new custom field group (means custom meta box)
Create a new custom field group (means custom meta box)

I set ID for this field group is user-profile. Then, I created custom fields inside this group as First name, Last name, Description.

All the above information is text, so I created Text fields for First name and Last name and a Textarea field for Description.

Create fields for User Profile
Create fields for User Profile

If you want the user profile has an avatar and title, just create additional fields with the correspondence type.

For your quick reference, this is the instruction to create the basic fields using Meta Box.

After creating all the essential fields, still in the Edit Field Group screen, go to the Settings tab, choose Users in the Show for item.

Set the custom fields to show for Users

Finally, press Publish to save these custom fields.

Step 3: Create “My Account” page in the frontend

This page is where the guest author manages and updates their profile.

Create a template for My Account page

First, create a new file named page-account.php in the theme folder with the content as below:

<?php
/*
*     Template Name: My Account
*/
?>

Aside from that, add this code to the file:

<?php if ( !is_user_logged_in() ) {
       auth_redirect();
} ?>

This forces users to go to the login page before access My Account page if they haven’t logged in any account yet.

Create My Account page

Back to the admin dashboard, go to Page > Add New to create a new page.

Create a new page
Create a new page

I set its name is My Account. In the edit page of this page, go to Page Attributes > Template in the right sidebar, then choose a template named My Account. This is the template created in the previous step.

 

Choose a template for the My Account page
Choose a template for the My Account page

Now, save the page.

Show content and the essential fields in the My Account page

Open the file page-account.php once again, add the the_content() function right after get_header() and before get_footer().

For your quick reference, this is the whole code for this file which I made with Twenty Seventeen theme:



This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters


<?php
/**
* Template Name: My Account
*/
if ( !is_user_logged_in() ) {
auth_redirect();
}
get_header();
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) :
the_post();
the_content();
endwhile;
?>
</main>
</div>
</div>
<?php get_footer(); ?>

Back to the edit page of the My Account page in the admin area, add the below shortcode to its content:

[ mb_user_profile_info id="user-profile" label_submit="Update" ]
Add shortcode to the content of the My Account page to show all the fields
Add shortcode to the content of the My Account page to show all the fields

In there:

  • mb_user_profile_info: Shortcode to show the form of the user profile;
  • id: ID of the Custom Field Group;
  • label_submit: this is the label of the submit button. I set it is Update.

Apart from that, there are dozens of shortcode which MB User Profile supports. You will find out more here.

Then, save the page and go to My Account page in the frontend. You’ll see something like this:

 Account page background
This is my My Account page

In addition, if you allow users to change their passwords from the My Account page, add this below shortcode to the content of that page:

Lost password

Please enter your username or email address. You will receive a link to create a new password via email.

So, you’ve finished the page to manage the user profile in the frontend already.

Allow guest user to submit posts in the frontend

Post submission in the frontend is the same as the listing submission which we had an instruction to do in the post How to Create a Classified Ads Website using Meta Box.

Step 1: Create a Custom Field Group

As creating a field group for the user profile, I created a new field group as following:

Create a new field group

In my case, fields for the post submission just include title and content, so I did not create any sub-fields inside this field group. In your cases, if you need any further fields, just add them as you want.

You will see the shortcode of the field group when you go to Meta Box > Custom Fields.

Shortcode of the field group
Shortcode of the field group

Copy and save it somewhere.

Step 2: Create the Post Submission Page in the Frontend

Create a new page by going to Page > Add New. Then, paste the above shortcode into the content fields of this page.

Create the post submission page
Create the post submission page

Save it and go to this page in the frontend, you will see this:

The post submission page in the frontend
The post submission page in the frontend

Step 3: Set a Layout and Login Requirement for the Post Submission Page

The post submission page has the same layout and requirements that users must log in before access as the My Account page. So, I do the same actions to this page as the My Account page as following.

Create a file named page-submission.php in the theme folder with the content copied from thepage-account.php, but changed the template name.

<?php
/*
*     Template Name: Publish Post
*/

?>
<?php if ( !is_user_logged_in() ) {
       auth_redirect();
} ?>

The whole code of my post submission page is below:



This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters


<?php
/**
* Template Name: Publish Post
*/
if ( !is_user_logged_in() ) {
auth_redirect();
}
get_header();
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) :
the_post();
the_content();
endwhile;
?>
</main>
</div>
</div>
<?php get_footer(); ?>

After that, go back to the edit page of this submission page in admin, choose the template named Publish Post (which I set in the page-submisson.php file) in the Page Attributes section.

Add a template for the post submission page
Add a template for the post submission page

Now, you’ve finished already.

Finish setting a Layout and Login Requirement for the Post Submission Page

Final Words

Well, we have created two pages which are My Account and Post Submission for the Guest Author. Please pay heed that we need to install all three extensions from Meta Box to do the above execution. Especially, thanks to Meta Box Builder, I created custom fields easily without touching any line of code in some steps.

We will use this plugin and its extensions in the next part to solve the 3rd and 4th requirements, which are the guest post review and management.

Other case studies you might be interested in

  1. Create A Dynamic Landing Page in WordPress Using Custom Field
  2. Create a Filter to Find Hotels by Location
  3. Create an OTA Website Like Booking.com with Meta Box Plugin - P1: Create a Page to Introduce Hotel Rooms
  4. Create an OTA Website Like Booking.com with Meta Box Plugin - P2: Create Filters on the Archive Page
  5. Create an OTA Website Like Booking.com with Meta Box Plugin - P3: Create Filters for Single Hotel Pages
  6. Create Dynamic Favicon in WordPress using Meta Box plugin
  7. Create Posts Series in WordPress Using Meta Box
  8. Display a User List On the Frontend with Meta Box
  9. Display The Latest Products Section - P2 - Using Meta Box and Elementor
  10. Display The Latest Products Section - P3 - Using Meta Box And Oxygen
  11. How to Add Custom Fields to Display Banners using Meta Box Plugin
  12. How to Add Guest Author in WordPress using Meta Box (Part 1)
  13. How to Add Guest Author in WordPress using Meta Box (Part 2)
  14. How to Add Related Posts to WordPress Using Meta Box
  15. How to Build a Hotel Booking Website Using Meta Box - P1
  16. How to Build a Hotel Booking Website Using Meta Box - P2 - Booking Page in Backend
  17. How to Build a Hotel Booking Website Using Meta Box - P4 - Booking Management Page
  18. How to Build a Hotel Booking Website Using Meta Box – P3 – Booking Page for Customer
  19. How to Create a Classified Ads Website using Meta Box
  20. How to Create a Product Page - P2 - Using Meta Box and Oxygen
  21. How to Create a Product Page - P3 - Using Meta Box and Bricks
  22. How to Create a Product Page - P4 - Using Meta Box and Elementor
  23. How to Create a Product Page - P5 - Using Meta Box and Gutenberg
  24. How to Create a Product Page using Meta Box Plugin
  25. How to Create a Recipe - P2 - Using Meta Box and Oxygen
  26. How to Create a Recipe - P3 - Using Meta Box and Elementor
  27. How to Create a Recipe - P4 - Using Meta Box and Bricks
  28. How to Create a Recipe - P5 - Using Meta Box and Zion
  29. How to Create a Recipe - P6 - Using Meta Box and Brizy
  30. How to Create a Recipe - P7 - Using Meta Box and Breakdance
  31. How to Create a Recipe with Meta Box Plugin
  32. How to Create a Simple Listing - P2 - Using Meta Box and Bricks
  33. How to Create a Team Members Page - P1- Using Meta Box and Elementor
  34. How to Create a Team Members Page - P2 - Using Meta Box and Oxygen
  35. How to Create a Team Members Page - P3 - Using Meta Box and Bricks
  36. How to Create a Team Members Page - P4 - Just Meta Box
  37. How to Create a Team Members Page - P6 - using Meta Box and Breakdance
  38. How to Create a Video Gallery Page Using Meta Box + Oxygen
  39. How to Create ACF Flexible Content Field with Meta Box
  40. How to Create an Auto-Updated Cheat Sheet in WordPress
  41. How to Create an FAQs Page - P1 - Using Meta Box and Elementor
  42. How to create an FAQs page - P2 - Using Meta Box and Oxygen
  43. How to Create an FAQs Page -P3- Using Meta Box
  44. How to Create Buttons with Dynamic Link using Custom Fields
  45. How to Create Category Thumbnails & Featured Images Using Custom Fields
  46. How to Create Download Buttons Using Custom Fields with Meta Box Plugin
  47. How to Create Menus for Restaurants - P1 - Using Meta Box and Elementor
  48. How to Create Menus for Restaurants - P2- Using Meta Box and Bricks
  49. How to Create Online Admission Form for School or University
  50. How to Create Online Reservation Form for Restaurants using Meta Box
  51. How to Create Taxonomy Thumbnails & Featured Images - P2 - Using Meta Box and Oxygen
  52. How to Display Images from Cloneable Fields - P1 - with Gutenberg
  53. How to Display Images from Cloneable Fields - P2 - with Oxygen
  54. How to Display Images from Cloneable Fields - P3 - with Elementor
  55. How to Display Images from Cloneable Fields - P4 - with Bricks
  56. How to Display Opening Hours for Restaurants - P1 - Using Meta Box + Gutenberg
  57. How to Display Opening Hours for Restaurants - P2 - Using Meta Box and Oxygen
  58. How to Display Product Variations - P1 - Using Meta Box and Gutenberg
  59. How to Display Product Variations - P2 - Using Meta Box and Oxygen
  60. How to Display The Latest Products - P5 - Using Meta Box and Bricks
  61. How to Display the Latest Products - P6 - using Meta Box and Breakdance
  62. How to Display the Latest Products Section - P4 - Using Meta Box + Zion
  63. How to Display the Most Viewed Posts - P1 - using MB Views
  64. How to Display the Most Viewed Posts - P2 - using Meta Box and Oxygen
  65. How to Filter Posts by Custom Fields - P2 - using Meta Box and FacetWP
  66. How to Manually Reorder Posts with Meta Box
  67. How to Show Featured Restaurants on Homepage - P1 - Meta Box + Elementor + WP Grid Builder
  68. How to Show Posts with Specific Criteria - P1 - Using Meta Box and Bricks
  69. How to Show Posts with Specific Criteria - P2 - Using Meta Box and Oxygen
  70. How to Show the Featured Restaurants - P3 - using Meta Box and Oxygen
  71. How to Show the Featured Restaurants Section - P2 - Using Meta Box and Bricks
  72. How to Use Custom HTML Field to Output Beautiful Texts or Output Custom CSS

Leave a Reply

Your email address will not be published. Required fields are marked *