I need some suggestions for some custom functionality

Hey all! I just signed a new client, and I need to figure out a few bits about the project. I was hoping to have a bit of a discussion about how you all might go about piecing this one together. It could make for a nice creative conversation.

Without giving away the full concept of my client's website, I am creating a niche social network. This social network is a bit different, because instead of everyone having the same kind of account, I need to figure out how to allow people to sign up as 2 different user types. For the sake of simplicity, I will call them USER-A and USER-B.

First, USER-A and USER-B have to have different information in their profiles.

Second, USER-B should be able to contact USER-A, but USER-A should not be able to contact USER-B directly.

Third, all users can comment on other users' profiles.

Fourth, ***This one is fairly specific*** ... USER-A should have the ability to upload custom posts to their profile for other users to read and comment on. These posts should be associated to this user's profile only. This user should get notified when a comment is submitted to their own posts.

Fifth, the owner of the website (my client) should be able to submit announcements to all users of the website. This could be email notification, or this could be on an announcement page.

These are items that can be loosely interpreted, and I would love for us to discuss the possibilities of this project. This is by no means a way for me to have my work done for me, however, I acknowledge the power of this community and would love the productive feedback of the wonderful members of this forum.

Thanks so much in advance, and I am looking forward to your suggestions and comments!

Cheers!

  • Tyler Postle

    hey Mediastead,

    I'd be happy to throw some suggestions your way :slight_smile:

    I need to figure out how to allow people to sign up as 2 different user types. For the sake of simplicity, I will call them USER-A and USER-B.

    First, USER-A and USER-B have to have different information in their profiles.

    Gravity Forms is great for this! I have posted a screenshot below that illustrates the options available for registering a user (integrates with BuddyPress).

    The only catch with this one is that you need a Gravity Forms developer license ($199) to be able to access the "User Registration Add-on"; however, Gravity Forms is an awesome plugin and you would likely end up using it on every site you create after trying it out.

    Second, USER-B should be able to contact USER-A, but USER-A should not be able to contact USER-B directly.

    If you find the permission that is needed for a user to be able to send messages through buddypress then you can use this User Role Editor plugin to take that permission away from certain roles. I haven't personally tried this method yet but in theory I think it may work!

    Third, all users can comment on other users' profiles.

    BuddyPress allows you to "@mention" another user and it will show up in their mentions on their profile page :slight_smile:

    Fourth, ***This one is fairly specific*** ... USER-A should have the ability to upload custom posts to their profile for other users to read and comment on. These posts should be associated to this user's profile only. This user should get notified when a comment is submitted to their own posts.

    How big of posts are talking? Like a status update sort of thing? That is already built into BuddyPress and it allows comments from other users.

    If you want to allow full on posts, then you can incorporate a front end post editor and restrict that to User A only, by either using the User Role editor plugin above OR using our Membership plugin and protecting the front end editor page. When they make a post it will show up an excerpt in their activity feed on their profile where another user can either comment on it or click and go straight to the full post and comment on it their.

    Fifth, the owner of the website (my client) should be able to submit announcements to all users of the website. This could be email notification, or this could be on an announcement page.

    You could create an announcement BuddyPress group which would have a separate activity stream. Members of the group can be notified when updates are posted and can also comment on them!

    I hope that gives you a solid base to start off of! If I think of anything else I will be sure to post back here for you :slight_smile:

    All the best,
    Tyler

  • mediastead

    This is certainly a fantastic start! I am going to have so much fun fitting all of these moving parts together.

    I feel I may have to give a small amount of real project data for us to figure out the best way to build this part.

    USER-A will be a book author, and when I was asking about posts, what I really need to happen is for the author to be able to input their books into their profiles. Not full books, but sample chapters of their books. Attach a photo of the cover and put meta data, tags and categories.

    From the front end of the website, people should be able to search the website by author (User), or go to the book section and sort the books by genre, tag, author, etc.

    The social aspect really kicks in 3 levels deep. There is the website front end, where people have various ways to browse an author's books, once they click through, they either click on the author to see a listing of all their books, or they click on a specific book first, and then find the author profile after.

    Then there is the logged in interface where a user can upload their books and add chapter samples and cover art, etc. To their profile.

    I hope this is more clear.

    Cheers!

    Thanks so much for the replies!

  • mediastead

    Okay, I thought about this more, and have come up with more of the picture. Basically, a post has everything I would need to create "book summaries". The title of the post is the book title, the excerpt is the book summary, the featured image is the cover, categories (taxonomy) is the genre... I am stuck on a few points:

    Point 1: If the author wants to give multiple sample chapters.
    Point 2: How can I restrict a user's account to only show their posts?

    My take on point 1: Can I use something like Advanced Custom Fields to create a way for the author to continue to add chapter samples until they're done? I don't know if the ACF plugin has a field that comes with an "add" button, so the user can continue to add more fields of the same type (in this case, text editor).

    My take on point 2: What I need is a unique login for every user, and when that user logs into their account, they can edit their profile, and add books that would be attached to their profile. When another logged in user browses the website, they can search for content by author, or by book. Both the author section and the book section are sortable by genre (taxonomy). If you click on an author, you see only their books. If you click on a book, it takes you into the "post" where you can read the chapter samples etc...

    ---

    That brings me to my next question. Is it possible to attach a taxonomy to a user automatically, once they attach that taxonomy to one of their own posts?

    So, an example would be ... I am a user and I just added a book, I clicked that it is a horror book. When a person goes into the author section and sorts the authors by genre, I want to be included in the horror section automatically, so I don't have to toggle "horror" in a separate "user taxonomy" section.

    WOW lots of great Wordpress functionality that can be super useful for many applications! I hope this conversation helps other people figure some cool stuff out!

    Thanks for the answers so far.

  • Tyler Postle

    Hey Mediastead,

    Another way you could go if you wanted to keep the basic post for your blogs is create custom post types. This plugin here: https://wordpress.org/plugins/custom-post-type-ui/ is very popular for this. Essentially you are creating your own post type that you can design specifically for books. There are some really good tutorial videos you can find on Youtube for this plugin too :slight_smile: - Combine it with the advanced custom fields plugin.

    Point 1: If the author wants to give multiple sample chapters.

    You could add the sample chapters to the main content box and protect them to a certain membership level with our Membership plugin OR you can password protect the sample chapter content so the author has to give out the password before his/her users can view it - we have a plugin for this too: https://premium.wpmudev.org/project/password-protect-selected-content/

    You have a lot of options with this one. You could also setup a subscribe form and allow the authors fans/readers to subscribe and then they get sent a sample chapter :slight_smile: Helps build a list for future book releases.

    Point 2: How can I restrict a user's account to only show their posts?

    By default in WordPress if you go to the domain.com/author/username link it will show only posts from that specific author. So you could do this then customize the way the content is shown. ie. for each entry have an image(book cover) and excerpt. The author link is separate from the BuddyPress profile so if you wanted to create a link on each persons profile that goes to their "author page" that has the list of their books then this is definitely do-able.

    That brings me to my next question. Is it possible to attach a taxonomy to a user automatically, once they attach that taxonomy to one of their own posts?

    If you use the method above for displaying author's books then simply having a "Horror" Category will be enough. You can likely find a plugin that will allow you to filter the author page by category :slight_smile:

    WOW lots of great Wordpress functionality that can be super useful for many applications! I hope this conversation helps other people figure some cool stuff out!

    WordPress is an incredible piece of software. There really is no limit! Definitely post back when your finished this project, I'm sure lots of people would love to see how the finished project looks (myself included).

    Hope this helps!

    Cheers,
    Tyler

  • mediastead

    So, I'm looking at Gravity Forms, but I am also looking at your Membership plugin, and I really don't know which one (or something else completely?) would be best for this project.

    I am going to have 3 "user types" ... Readers, Writers and Publishers.

    A Reader can go onto the site and pretty much see everything, but they won't have user profiles. They also won't be able to comment without "signing up" with a username, email, and password.

    A Writer and Publisher will have a full profile. Writers and publishers will have different custom fields from each other. Because they will have different information in their profiles, I need them to be able to sign up as the correct user type, and have their account associated to the correct user role.

    I need a way to have a registration from that allows a user to choose what "person type" they are, and they are registered under the correct user role. Also, if it is possible, I'd like them to be able to have the option of filling out the custom profile fields during registration, which means that when the person chooses their type, the form should change, depending on the type chosen, and when submitted, the user should be submitted to the correct role.

    Is any or all of this possible?

  • mediastead

    Okay ... I got the user registration working. I now have 2 user types and one registration form.

    Now I need to implement the second part of the functionality:

    I have writers and publishers. The writers need to be able to add books to their profile, and they need to be able to add a book summary, and multiple chapter samples (as many as they want) to the book, as well. The book will have a cover photo, and the books will be added to the user's profile. Once the book is clicked on, the summary, and sample chapters will be on the book page, and can be clicked through to be read.

    Books can also be commented on and "liked".

    Any ideas?

  • Tyler Postle

    Hey Media,

    Hope you're doing well today and thanks for your patience here :slight_smile:

    I have writers and publishers. The writers need to be able to add books to their profile, and they need to be able to add a book summary, and multiple chapter samples (as many as they want) to the book, as well. The book will have a cover photo, and the books will be added to the user's profile. Once the book is clicked on, the summary, and sample chapters will be on the book page, and can be clicked through to be read.

    Are you looking for suggestions on how to create the form? Or custom post type? Or maybe both? Sounds like you are wanting a custom post type that your users can submit to from the front end?

    Any ideas about how to actually differentiate the user roles, with their different profiles?

    Are you wanting to display the user role on their profile? Perhaps something like this will help: http://wordpress.org/support/topic/display-user-role-on-profile-page

    Are you using BuddyPress? I took a quick look above and couldn't remember if that's what you used or not here.

    Look forward to your reply Media!

    Cheers,
    Tyler

  • mediastead

    Hey @Tyler,

    I am using BuddyPress.

    I have a good handle on how to create the custom post type, and I was going to create custom taxonomy to handle the genre of book. I can do custom fields for book summary (or maybe just use content and excerpt for summary), and custom fields for chapters.

    Where I am floundering is whether or not I can create a custom field for the chapters and give the writers a way to click an add button or something to continue to add chapter samples until they're done?

    So, a combination of custom post, custom taxonomy and custom fields can probably get the book section working for me.

    Sticking point...I need every writer that signs up to be able to add books to their BuddyPress profile. From the front-end would be slick, but back-end editing is acceptable.

    My other issue is that all the members are clumped into one group called "members", but I took the time to figure out how to get the registration form to separate them into user roles...so, now I just need to figure out how to display writers and publishers in their own sections.

    It's a fun project. Lots of custom stuff happening. The more I talk it out, the clearer the concept becomes in my mind. Just have to figure out the best approach from within Wordpress.

    I think that is all for now. Once I get a handle on separating the writers and their books from the publishers, I think everything else will come together.

    Thanks for your time!

  • mediastead

    Okay ... I have a ton of this project figured out. I created the books and chapters functionality. I have most of the functionality locked down on a user role basis. I created the custom registration with Gravity Forms that allows a person to choose their user type.

    A few items that I still need help figuring out:

    I need to figure out how to create a different Buddypress Profile for each user role. Right now, if I go in and create a profile field group, all fields and groups show up on every role.

    I'd like to be able to associate different profile fields and groups to each user type.

    ---------

    Also, I don't know if this in an issue of not, but in order to get the Gravity Forms registration to work, I had to go into the Buddypress settings, and make sure that I left the "registration page" blank for Buddypress. Now, I get this message:

    The following active BuddyPress Components do not have associated WordPress Pages: Register. Repair

    Is that okay?

    Once I figure out how to display a different profile for each user type, and allow them to edit their own custom profiles, I'll be very close to completion.

    Any ideas? I keep finding a suggestion for an outdated plugin, so I am pretty much stuck right now.

    Cheers!

  • Michelle Shull

    Hey there, mediastead!

    1. If your users are showing up in the BuddyPress members list after signing up with the Gravity Forms registration form, it should be working fine, in spite of the error. If new members aren't making it into BuddyPress, that would be an issue.

    2. I don't know of a way off the top of my head to differentiate profiles based on member levels. Points plugins like Cube Points and MyCred can both create member levels based on points, and both will allow you to display badges or awards on member profiles, you might play around with either of those and see if you can easily delineate members.

    Hope this is helpful!

  • mediastead

    REGARDING MAKING 2 DISTINCT PROFILES BASED ON USER ROLE.

    Okay ... So, I went through some of the Buddypress code, and found this:

    function bp_profile_group_tabs() {
    global $bp, $group_name;
    if ( !$groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' ) ) {
    $groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
    wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
    }
    if ( empty( $group_name ) )
    $group_name = bp_profile_group_name(false);
    $tabs = array();
    for ( $i = 0, $count = count( $groups ); $i < $count; ++$i ) {
    if ( $group_name == $groups[$i]->name )
    $selected = ' class="current"';
    else
    $selected = '';
    if ( !empty( $groups[$i]->fields ) ) {
    $link = trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . $groups[$i]->id );
    $tabs[] = sprintf( '<li %1$s><a href="%2$s">%3$s</a></li>', $selected, $link, esc_html( $groups[$i]->name ) );
    }
    }
    $tabs = apply_filters( 'xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name );
    foreach ( (array) $tabs as $tab )
    echo $tab;
    do_action( 'xprofile_profile_group_tabs' );
    }

    Which builds out your profile edit tabs, when you create profile groups in the backend.

    After I found this, I went to my bp_custom file, and wrote:

    add_action( 'xprofile_template_loop_start', 'mar_define_profile_by_role' );
    function mar_define_profile_by_role() {
    global $current_user;
    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);
    if( $user_role == "writer" ) {
    // Execute writer specific code
    } elseif( $user_role == "publisher" ) {
    // Execute Publisher specific code
    }
    }

    Can anyone help fill in the blanks? Basically, from the first code block, I need to figure out how to filter out the specific profile group from the array, with the correct section of my second code block.

    Example:

    I have 2 profile group tabs ... a Writer tab, and a Publisher tab. Each tab has user role specific profile fields.

    if( $user_role == "writer" ) {
    // Execute Writer specific code
    // Some kind of filter that removes the publisher profile group
    } elseif( $user_role == "publisher" ) {
    // Execute Publisher specific code
    // Some kind of filter that removes the writer profile group
    }

    Within the first block of code, the piece of code that sticks out the most for me is:

    $tabs = apply_filters( 'xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name );
    foreach ( (array) $tabs as $tab )
    echo $tab;

    I think this is the code that actually loops through all the profile groups and spits them onto the page. If there is an "apply_filters", I should be able to tap into this, right?

    What do you think. Any suggestions?

    I'll keep working on this.

    Cheers!

  • mediastead

    Okay .. well, I figured out this last part. I have a new predicament (the Buddypress Codex is fairly useless):

    I have a custom post type that I set up and have the permissions set so that my Buddypress users can edit the custom post type.

    I would like to put a link on everyone's profile, so if you click through the link to the custom post types, it will pull and display ONLY the member's posts that you clicked on.

    How might I go about doing this?

    Cheers!

  • mediastead

    Scratch that ... It is working, but not completely optimized.

    If you go here:
    http://chaptersee.mediasteadbeta.com/members/mrapino/profile/

    and click on "my books", it takes you to the author archive, with my custom post type streaming in, which is great.

    What would be better is if I can load the author archive within the Buddypress profile, so I can retain the nice Buddypress nav bar.

    Any ideas??

  • Michelle Shull

    Hey there, mediastead!

    I think I might see the issue! Your author archives are displaying in a WordPress archive template, not in the BuddyPress profile template. I think you're really close, in other words. : )

    I found two links I think might help you put this last piece together, this one from Stack Overflow: http://wordpress.stackexchange.com/questions/16223/add-buddypress-profile-menu-item

    and this one: http://blog.maximusbusiness.com/2013/06/buddypress-profile-custom-bp-menu/

    I think you've got the menu tab in order, it's just not generating the content within the BP profile template for you.

    Hope this helps!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.