Create profile page with login

I have to create a page where someone can login and create a profile, they would then have an option to create a template page report and submit it for review to be published by an editor live on the site. What would be the best way to go about this plugins coding etc?

  • Adam Czajczyk

    Hello Gary,

    I hope you're well today and thank you for your question!

    I think the good starting point would be the BuddyPress plugin. It will let you add additional fileds to the registration form and user profile so you could gather all the information you request from user.

    It will also let users register on "front-end" and easily fill in/update/manage their profiles.

    As for creating "template page report". This is a little bit more "tricky" because I'm not sure how exactly should such a "template page report" work/look.

    There are many plugin that would let you registered users to post content from a front-end and here's a nice review of some of them, I think you may find that interesting:

    https://premium.wpmudev.org/blog/wordpress-post-frontend-plugins/

    However, it would be great if you could let me know something more about that "template page report" (how should it work/look etc). I believe I could then provide you with better advice on this :slight_smile:

    Best regards,
    Adam

  • Gary

    Hi thank you for the prompt response. My client sent me a layout for a research journal in a word doc, has paragraphs and photos to be able to replace here and there. I don't know if it is possible but a front end editor would be a great option if not maybe I could have user sign up and then go in to posts and add a post using a template post file like visual composer for example, but for this particular project I am probably going to use X Theme which has cornerstone. Hope that clears things up. I would think in worse case scenario I would need to just make a template post that an editor can duplicate and modify from student submitted word files and manually push out since they need to be reviewed before being published anyway. I just never did something quite like this before.

  • Adam Czajczyk

    Hello Gary!

    Thank you for this additional explanation :slight_smile:

    I think this can be achieved. The first part - the registration and user profile - would be handled by BuddyPress plugin like I suggested previously.

    The "template" part would be a bit more complex so let me try to put some more light on this :slight_smile:

    1. You would want to reproduce the "template" that you client provided you with - in a form "understandable for WordPress". First step would be to create a custom post type that would server as you "template report". Here's more about WP custom post types:

    https://codex.wordpress.org/Post_Types#Custom_Post_Types

    You can create them "manually" (by adding some code to the "functions.php" file of your theme" but you can also use our "CustomPress" plugin for this.

    Then you could use the same plugin to create custom fields (see more about custom fields here: https://codex.wordpress.org/Custom_Fields)

    This custom fields would be holding all the data that would be part of that report (are the part of the "template report").

    Then you would want to create a custom page template for the custom post type that you created. See here for more information on custom page templates:

    https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

    In this template file you would include values of custom fields that you created. This is also explained in that article on custom fields that I linked to above.

    Finally, you would want to add a front-end posting option so I think the Gravity Forms plugin would do the job for you. Take a look at this article please:

    https://gravitywiz.com/use-gravity-forms-to-create-user-submitted-posts/

    All that together sounds a bit complex but after all it's easier that it seems and I believe it would let you build a site that would nicely suit your goal :slight_smile:

    Best regards,
    Adam

  • Gary

    So far the problem I am running into is that the custom fields I create aren't showing on the front end. So I am using gravity forms with the post fields when it is submitted and I view the page it does not show the content, it only shows when you view the draft that was created (of course if I publish the draft I get the same results, no 404 error just a blank entry it shows title, default body text, and meta post info only). Do I need to add extra code to get my custom post type's custom fields to show live?

  • Adam Czajczyk

    Hello Gary!

    I understand that you do see a "table" with custom fields and their values in the back-end (e.g. when you access post via "Posts -> [edit post]" WP editor), is that correct?

    That would mean that fields are created properly and Gravity Forms front posting works well. In order to display these fields on front-end you would need to fetch them in your custom page template.

    Let's say that your custom post type is named "report". Therefore you would want to create a custom page template file called "single-report.php" in your theme's folder.

    See this article please for more information on how to create custom page templates: https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

    Inside that template (within the "WordPress loop") you will want to "call out" your custom fields with "get_post_meta()" function.

    Let me give you a simple example :slight_smile:

    1. Assuming that the custom post type is "report" the custom page template file would be "single-report.php".

    2. This is the simplest example of a WordPress loop:

    <?php
    if ( have_posts() ) {
    	while ( have_posts() ) {
    		the_post();
    		?>
                     <h2><?php the _title(); ?>
                    <div class="post">
                          <?php the _content(); ?>
                     </div>
                     <?php
    	} // end while
    } // end if
    ?>

    3. Assuming that there are two custom fields - "location" and "subject" - you would want to call them like this inside the loop (in a "single-report.php" file):

    <?php
    if ( have_posts() ) {
    	while ( have_posts() ) {
    		the_post();
    		?>
                     <h2><?php the _title(); ?>
                    <div class="post">
                          <?php the _content(); ?>
    
    <div class="custom-fields">
    
    <?php echo get_post_meta($post->ID, 'location', true); ?>
    <?php echo get_post_meta($post->ID, 'subject', true); ?>
    
    </div>
    
                     </div>
                     <?php
    	} // end while
    } // end if
    ?>

    This is simplified and you will most likely want to add more lines fetching your custom fields and also wrap them all in an additional HTML/CSS but I think it should give you a good start.

    Best regards,
    Adam

  • Gary

    Hi thanks for the help with that. Everything is working well so far I seem to have an issue when I add a new category, it shows the category on the front end and it is clickable as well, I do not get 404 error however I do not see any posts that fall under that category. So if I click the category link it will take me to category/journal-entries/ which is fine, the header sidebar is there its just missing the content, not sure what I need to do for it to show. I included my code for registering the custom content (thanks to you of course)

    //Custom post type
    add_action( 'init', 'create_post_type' );
    function create_post_type() {
      register_post_type( 'student_journal',
        array(
          'labels' => array(
            'name' => __( 'Journals' ),
            'singular_name' => __( 'Journal' )
          ),
          'supports' => array( 'title', 'editor', 'thumbnail', 'revisions' ),
           'taxonomies' => array('post_tag','category'),
           'show_ui' => true,
          'public' => true,
          'has_archive' => true,
          'rewrite' => array( 'slug' => 'student_journal' ),
        )
      );
    }
  • Dimitris

    Hey there Gary,

    hope you're having a beautiful day!

    To display an archive page according to Custom Post Type Templates codex page here

    https://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

    you should create an archive-report.php template and echo the appropriate loop and additional post meta data that you've created. A good head start would be to copy archive.php (or even index.php if archive.php doesn't exist) from your parent theme to your child theme folder and rename it to "archive-report.php". :wink:

    Hope that was some help,
    Dimitris

  • Gary

    Hi my day is going great, thank you for asking. Hope everything is good on your side. I actually created the archive-student_journal.php file last night and I did just that I copied the archive template from the Avada theme I am using. It shows the page when you click the category, it is just missing the archived content that would fall under that category I created under the custom post type, so I am not 100 percent sure at this point I will read over the codex and see if there is something I am possibly missing.

  • Predrag Dubajic

    Hi Gary,

    Archive templates usually just have functions to pull some default values from your posts, featured image, title, content, excerpt, etc. and if you need to show custom fields in there it would require adding those to your archive page as well.

    If you already have it configured to pull that data in single post you can use the code from there and add it to your archive query to show custom field values as well.

    Best regards,
    Predrag

  • Gary

    So I ended up scratching the custom post type, since the theme I was using doesn't have much support for it. I ended up just creating a new category under the default blog instead with the custom fields assigned to in which are then pulled from gravity form entries, creates the draft post and then template is loaded via fusion builder . I used an additional plugin to redirect users who login to the system to go right to the submission form, and used wp members to hide the page when someone is not logged in.

    Thank you both for your help on this!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.