Skip Navigation

[Resolved] Membership based review site – User Profiles, Products and Reviews

This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.49 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Author
Posts
#397905
Screen Shot 2016-05-13 at 3.55.42 PM.png

Ok so.....

I am trying to:

Build a book review site.

I want users to be able to sign up and create a profile page (custom post - User Profile)

I want users to be able to submit books (custom post - Book)

I want users to be able to review books (custom post - Book Reviews)

So the User Profile and Books posts will be parents of the Book Reviews.

On the Book posts, there will be a view to display all the different reviews from different users of said book.

On the User Profile posts, there will be a view to display all the different reviews submitted by that user.

All the bells and whistles, custom fields, images, taxonomies, profile information etc, all completely searchable via parametric search

Toolset seems perfect for this... Yay!

I am now at the point of working out the user sign up and profile post creation, and have been looking through the forums for other users who have successfully implemented similar processes for membership sites.

I understand that at the moment I need a separate login form. Cred can do the registration and updating of standard wordpress profiles, and creating and editing profile fields:
https://toolset.com/forums/topic/create-a-membership-site/
https://toolset.com/forums/topic/any-news-regarding-user-profile-creation-management-via-cred/

Am I able to use standard wordpress profile pages as parent posts? Am I able to add the necessary book review views to users wordpress profiles?

Or is it better to do something like this:
https://toolset.com/forums/topic/cred-user-profile-editing/

Where once a user signs up they are forced to create a new 'User Profile' post, whenever they subsequently sign in they are taken to this profile page but only offered an edit link and can't create a new 'User profile' Post.

If I do it this way, how do I hide the native wordpress profiles?

Thankyou for your patience and help. I am currently going through all the tutorials figuring toolset out and building the tutorial sites, however there are no tutorials for a membership site. I found several seeming angry people venting about this, but I've only had toolset for a couple of days and am very happy with the potential so far.

Best

Jeff

-------------------------------------------
Addendum

Not specifically related to my problem, but the support forum asked for the debug information. To be found at admin>toolset>help.... For some reason this location does not exist for me (see image). I've searched the plugins pages and all the help dropdowns, to no avail, so I will be annoyed if the lack of this information slows down my support request.

Having said that, I have been known to be prone to bouts of extreme stupidity, so if I am being an idiot and someone can point me in the right direction, I will happily collect this data and pass it along.

#398057

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Firstly, re: the debug info, our bad, not yours:
https://toolset.com/faq/provide-debug-information-faster-support/

Now, for your membership site.

You want users to be able to register, have a profile on the site, write reviews of books. And you want to be able to display a user with all the reviews they have written, and to display a book with all the reviews of that book.

The main flaw with the set-up you are describing is how you treat your users. Your user profile custom post type is redundant.

When a user registers on your site (in your case you are going to use a CRED add user form for this) that creates a standard WordPress user. WordPress user profiles include certain standard fields for their name, their email address etc. Types allows you to add custom User fields for any other meta information your want to store and display about your users, e.g. their favourite author. You will see those custom fields if you are looking in the WordPress backend at the users, and those new custom User fields will be available to you while designing your CRED add user form.

With your user profiles taken care of, then, yes, you want to create a custom post type for Books with all the custom Post fields (before we were talking about custom User fields) you require, such as author, ISBN, publisher and so on.

Then create your Reviews custom post type as a child of Books. All Reviews will then be attached to a Book. You will use a CRED post form for your users to publish their reviews, ensuring that they are the authors of the review posts.

Now, on a page where you display a user profile you can add a View which shows reviews which includes a filter to only include reviews where the author is the same as the profile you are viewing.

And on a page where you look at a Book you can add a View to display all the child posts of the Book, i.e. all of its reviews.

That's the broad brush strokes of how you would go about it, hopefully the documentation will now help you fill in the gaps.

If you have any questions about the setup I have proposed please feel free to ask, but if when you are working on implementing it you come across more specific problems, it would be helpful if you started a new thread.

#398284

Hi Nigel, and thanks for your help.

Re: The debug info, I'm glad I'm not going crazy!

My site will not just be a review site it will also be an archive with details of authors and publishing houses so....

On my test site I have created Author Posts & Publisher Posts, these posts are parents of the Book posts. So on each Authors and Publishers page you can see their respective books. And on each Book page you can see and link to their Author and Publisher.

hidden link
hidden link
hidden link

Regarding the reviewing system, I was intending to set up a Users profile post type alongside the Book post type as parents of the Review post type after reading your CREDs documentation referring to an illustrative book review site:

https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

However if there are better solutions to display User profiles to all users on the front end without an unnecessary post type, I'm all for that!

So, I've followed your advice and created a CRED add user form. It's working fine, I can see the populated custom User fields in the backend.

I also created the review post type as a child of book posts, and an accompanying CRED post form for users to input their reviews and create review posts.

I have included the view for book reviews of books on their page, filtered as Children, that works.

hidden link
hidden link

Some problems:

1.1 Book review form populated with specified book.

At the moment I have included the book review form on the book post page, using the following shortcode:

[cred_form form='250' form_name='Book Review Form']

However as you can see from my previous link, the user needs to select the book from a dropdown, given that my site will include thousands of books, this is unwieldy.

I did this because when I tried to follow the instructions to create a link to a book review form, with the book already specified, here in the documentation:

https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

Specifically this step:

hidden link
child-link-into-post2.png

It wants me to enter a page ID?

I tried to enter the ID for the form but that returned a 404. If I enter a book page ID, it just links to that books post.

The documentation reads:

" This link will take the user to a page containing this form"

So I tried both creating a generic review post and review page (277) with the CRED form included which included the CRED form shortcode:

[cred_form form='250' form_name='Book Review Form']

And then linked to that page with the following shortcode in my books styling template:

[cred_child_link_form form='277' parent_id='-1' text='Review this book' target='_blank']

But for some reason that created and linked me to an archive-like page with all the reviews of the book.

So I reverted to having the reviews on the book pages, as a temporary stop-gap while I'm testing all this out.

Can you give me clear step by step instructions about how to have a link from the book post to the review form, with the review form book parent already populated in the drop down please? (as per the documentation)

Alternatively, is there any method to have the CRED review form on the book page, with the selection already populated correctly with the book that is being viewed?

-----

1.2. Multiple reviews per user

At the moment, when a user reviews a book, the next time they visit the book they can review the book again.

Is there anyway to amend this behaviour so that they can only edit their previous review?

Would this be possible via a conditional output? Displaying an edit user post link or form if the user had already created a child-review post for this book post?

-----

1.3. Other users reviews view at the bottom of a users review.

On a users book review post, is it possible to have a view that features other users reviews of the same book, similar to the book post?

The User review is a child of the book post. The other reviews are sibling posts, I didn't see any way to create views from siblings. I tried multiple combinations but couldn't get any to display.

-----

2. User profile pages with reviews:

So the user reviews appear at the bottom of the book posts, that's good. When I click on them, it takes me to the specific review. I have also added a view to the review post templates, so that other users reviews also appear there.

As you said:
"Now, on a page where you display a user profile you can add a View which shows reviews which includes a filter to only include reviews where the author is the same as the profile you are viewing."

So if I am no longer creating a user profile/reader page as per the documentation, I guess the user profile page is an archive page?

So I wanted to create a view as per your advice:
"includes a filter to only include reviews where the author is the same as the profile you are viewing."

However the language used for the options differs slightly, as follows:

A. Post author is the same as the logged in user
B. Post author is the author of the page where this View is shown
C. Post author is the author of the current post in the loop
D. Post author is set by the parent User View
E. Post author is <Start typing>
F. Author's ID is set by the URL parameter: <author-filter>
G. Author's ID is set by the View shortcode attribute: <author>

I have tried B,C,D and combinations of F and G, to no avail:

hidden link

-----------

So I understand you might want me to break down this support request into separate requests for the convenience of other users too, so please direct me as to what needs to be broken down and separated off.... I am writing it all down as it is the culmination of my days investigating toolset.

as I have another couple of queries.......

-------------

3. Submitting Books, Authors, and Publishers via CRED post forms.

With the Cred forms I can register a new user from the front end, I can submit a review from the front end too.

Thats great, but I as mentioned at the beginning my site also has Author and Publisher Archives.

So, I want to be able to use a CRED from to submit new books to the archive.

However would I be able to create 1 CRED post form that can submit data to Books, Authors, and Publishers Posts? Or would I need to create 3 separate CRED post forms, one for each?

--------------

4. Maintaining Front-End only User Experience for subscribers users.

When new users sign up there is an option to redirect them to another page, say the home page.

However, when they log in subsequently they go directly into the backend. Is there anyway to alter this behaviour?

If they are only subscribers then this is quite a sparse user experience. With my woocommerce sites, when users logged in they were always kept in the front end. My only other experience of using wordpress is woocommerce.

Does toolset have a solution for this, or can you recommend an alternative resource/plugin that plays nicely with it, that can allow me to control user experience in such a way?

---------------

Thanks for your patience, I apologise for the long request. I will separate it out as you see fit and look forward to your advice.

Best

Jeff

p.s. As you may gather from the content on my review site, it is a test install. It's purpose is to investigate the potential of toolset's application to a site analogous in function to a book review site, I hope none of the content offends.

#398449

With regards to:

3. Submitting Books, Authors, Publishers via CRED forms.

I created 3 different forms, and integrated them into one submissions page.

hidden link

It's not very elegant, but that will come later.

----------

4. Maintaining front-end user experience.

I have submitted a separate support request asking for advice

https://toolset.com/forums/topic/front-end-only/

--------

My priorities for this thread are:

1.1
working out the link on the book page to a review form that is populated with the correct book, as per:

https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

1.2
Stopping users from creating second reviews of the same book, but allowing them to edit their previous reviews

2
If not creating 'User Profile Posts', working out some 'page to display user profile'.
Being able to create archive pages for authors that only display their reviews.

--------

My recurring apologies for being so demanding.

#398672

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Thanks for splitting off Q4 into another thread, it can be addressed separately.

A brief comment about Q3. CRED post forms create (or edit) a WordPress post, either standard posts, pages, or custom post types. They can only ever create or update one post at a time, so if you want to create 3 separate posts (a book, an author, and a publisher) you would need 3 separate forms. A custom PHP solution is possible that would split a form and create separate posts, but is beyond the scope of the support we can offer.

Regarding whether you need to create a User post type as per the documentation you linked to. That documentation is for illustration, I would instead use the built-in WordPress users (embellished with additional User profile fields) as the post authors of their reviews as I described in my initial response.

So starting with Q2.

You have used CRED user forms to allow people to register on the site to be able to post reviews and you want a user profile page where anyone can view that user's details, including a list of their book reviews. If you are using built-in WordPress users as authors of the review posts then the built-in author archive is your starting point, which you can customise using Views.

See this page for general information about customising WordPress archive pages: https://toolset.com/documentation/user-guides/normal-vs-archive-views/

When designing your page you will have user profile info at the top of the page before your Loop contents which will list and link to your reviews.

--------- Q1.1 ----------
1. Create your form for submitting reviews. You can delete the part of the form which adds the parent post select box (recommended if you have 1000s of books).
2. Create a page where this form will be displayed and add your CRED form to it. We are going to need to know the id or name of this page in a moment.
3. Go to the Content Template you have created to display your Books. You will add a link here to the page where you display your create review form, using the CRED Forms button. Select 'Create Child Post Link', and 'Set the parent according to the currently displayed content'. You also need to tell it what page your create review form is shown on in the "Child Form Page" section. You can either enter the numeric id, or type the form name and a pop-up should appear which will insert the numeric id. (I don't think the documentation is very clear on this step.)

Now, when you view your book you will see a link to your create review form which adds the parent book via a URL parameter, and when you submit the form the parent will be automatically assigned.

--------- Q1.2 ----------
Limit users to one review per book.

This is trickier, and requires custom code.

What you are looking to do is in your Content Template which displays your Book, where you have added the link to your CRED form to create a review as described above, you need to conditionally display either the Create a review link or a similar Edit your review link (having set up a page to display the edit review form).

Your test is along the lines of "Does the current post (book) have a child post (review) whose author = the currently logged-in user".

You can see an example of the kind of thing that is involved in the code at the very end of this page: https://toolset.com/documentation/user-guides/many-to-many-post-relationship/.

That code example is missing your test for the post author being the currently logged in user.

I have written a simple function for this test, shown below, which you will need to add to your theme's funtions.php file. Note that the slugs for my Book and Review CPTs are 'book' and 'review' respectively.

/**
 * Custom function to check if current user has reviewed current book
 *
 */
function current_user_has_reviewed() {
	global $post;
	$current_post = $post->ID;
	$current_user = get_current_user_id();

	$args = array(
		'posts_per_page'   => -1,
		'meta_key'         => '_wpcf_belongs_book_id',
		'meta_value'       => $current_post,
		'post_type'        => 'review',
		'author'			=> $current_user
	);
	$reviews_of_current_user = get_posts( $args );

	return !empty($reviews_of_current_user); // will return true iff current user has reviewed this book
}

You need to register this custom function so that it can be used in your wpv-conditional shortcode. See documentation here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

That's a fair bit of ground covered, will hopefully keep you busy for a while.

#398698

Outstanding support Nigel, truly!

You are right, this will keep me busy for a while, but we are getting there.

I'll update this support thread later on, let you know how things are going and where I'm running into problems.

Thanks a million.

#398961

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Thanks for that Jeff.

If you have further questions can I encourage you to post them individually? It helps keep the forum threads to a manageable size and makes it easier for other users looking for help on related issues.

Thanks again.

#399427

Your welcome, writing me a function (no matter how simple you say it is) is above and beyond anything I could reasonably expect, much appreciated.

I shall post any further questions to a new thread and only keep this thread open until I have applied your advice above and let you know how it's gone.

Cheers Nigel

#399510

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Writing custom code is outside our normal support policy, but in this case it seemed a small extra step given what I had already outlined. Good luck with everything.

#399876
Edit page ID highlight.png
review page ID hightlight.png
edit review page.png
Submit review page.png
edit form ID.png
review form ID.png
edit book review form settings.png
Book review form settings.png
error.png

So just with regards to 1.1 and 1.2

1.1

Worked a treat. Thank you for your clear instructions.

1.2

I registered the function you so kindly wrote for me, and also registered 'is_user_signed_in'.

I created 2 conditionals, one nested inside the other.

Conditional 1 - Is the user signed in or not, if signed in then display condition 2, if not then show a login/register page link.

Conditional 2 - The conditional you helped me with.

[wpv-conditional if="( is_user_logged_in() eq '0' )"]
<a href="<em><u>hidden link</u></em>">Login/Register to Review this book</a>
[/wpv-conditional]
[wpv-conditional if="( is_user_logged_in() eq '1' )"]
[wpv-conditional if="( current_user_has_reviewed() eq '0' )"][cred_child_link_form form='337' parent_id='-1' text='Review this book' target='_blank']
[/wpv-conditional]
[wpv-conditional if="( current_user_has_reviewed() eq '1' )"][cred_child_link_form form='343' parent_id='-1' text='Edit your review' target='_blank']
[/wpv-conditional]
[/wpv-conditional]

If a user isn't logged in, it shows the correct link to the 'register/login' page.

If a user is logged in and has never reviewed a book it shows a link to the 'submit a book review' page.

If a user is logged in and has a previous review it shows a link to the 'edit your book review' page.

hidden link

all good.

except 1 problem, I couldn't edit the reviews.

The problem arises when I click the link to edit a users review. I get an error message where the form should be that reads:

'Edit form link can not be displayed (post type mismatch)'

I have attached screenshots of:
The error
The CRED book review form settings
The CRED edit book review form settings
The CRED post forms IDs
The Submit a book review page with CRED form shortcode
The Edit your review page with CRED form shortcode
The pages with ID's highlighted

Am I being an idiot? I know your customer service so your not supposed to suggest so, but really, you have my permission....

Everything seems to match up, the cred forms are for editing and submitting review type posts, all the forms shortcodes are correct, the links are correct.

The error appears under the title of the edit review page, so I figure the linking is all okay. The only thing I can think of, is that somehow because the link is appearing on the parent book page, then somehow I'm messing up and the system is expecting a form that will edit a book post.

Anyway, I look forward to your reply, and thanks for getting me this far 😀

Jeff

#399887

p.s. If I click the submit a book review link, then it takes me to a page with the form displaying correctly.

It's just the edit review post forms that is 'mismatching'

#400196

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

OK. Recap, for my benefit as much as for anyone else's reading this post.

Reviews are child posts of Books.

On a book page there is a link to post a review which takes you to a page with a CRED form to submit the review which has the parent book id pre-set so that the review will be attached to the right book.

Now when you revisit the book page, having already submitted a review, we now want a link to edit that review. We want to tell our CRED form that we are editing the review (not editing the book).

Here's the problem.

For CRED forms which create content the content doesn't yet exist, so you need to put the CRED form on a page.

When we want to edit content with a CRED form the content does already exist. So the default behaviour is that you will add your edit link to the thing itself that wants editing.

Unless we tell it otherwise, when we view the CRED edit form it thinks we are editing the content that was linked from. If you link to it from a dedicated page or from the book you will get type mismatch because books and pages are not reviews and your form is for editing reviews.

You either need to tell it otherwise, that you want to edit a particular review rather than the content where there link occurs, or you add the review link to the review.

See the documentation for the cred_link_form shortcode: https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_link_form

To add a link from your book to the relevant review you would need the post_id of the child post of the current book for which the author is the currently logged in user. That means writing more custom code (similar but different to what you already have).

Or, here's the alternative. Change your conditional shortcodes so that if the current user has a review for this book, don't show the "post a review" link, in fact don't post anything.

Then add a conditional to your View which shows the reviews inside your loop to add the CRED form link to the current review in the loop if the author is the currently logged in author.

That is your most straightforward option, I think.

#400219

OK, I understand.

I need the post_id of the child post, of the current book, for which the author is the currently logged in user...

haha

I just started to learn php, I can see how that function is similar to the one you wrote. Perhaps down the line I may get this done.

Option 2 works.

Change the conditional so when the current user has a review, the 'sign in/leave a review link' just disappears.

And add a conditional to my 'reviews for books' view, adding the 'edit your review' child post CRED edit form link to the current review in the loop if the author is the currently logged in user.

Basically the 'edit your review' link will appear in the table of reviews next to the currently logged in users review?

I'll have a go at that, and get back to you.

Jeff

#400223

One more thing...

If I am moving the edit link to inside the view, beside the currently logged in users review then...

If there are many reviews then the currently logged in users review could be somewhere in the middle or worse the bottom of the long long list...

I looked to see if I could order the view, with the currently logged in users review at the top. It doesn't seem possible. (Please correct me if I'm wrong and I'll work it out.)

So my solution is....

I will add another view above the current view that will only show the currently logged in users review. I will title this, 'Your review' and add the edit review cred form link to it.

However this raises a further small problem (and only really noticeable when the site isn't populated with many reviews)

The currently logged in users review, will appear in both views, duplication.

I looked to see if there was a way to filter out the currently logged in user, if i could have ordered the view so that the currently logged in users review appeared first then I could skip the first item. However it doesn't seem possible.

Can you confirm that's the case (unless I use custom code) and I will probably learn to live with the small duplication problem.

Cheers
Jeff

#400231

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

You are entirely correct about option 2.

You might revisit it and switch to option 1 when you are little more confident in your PHP. You will want to make a function that returns the post_id, and it would be better if you wrote it to add a custom shortcode that returns it so you can use that shortcode directly in your cred_link_form shortcode for the post parameter.

See the WordPress codex about writing custom shortcodes (https://codex.wordpress.org/Shortcode_API) or try google if that is confusing.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.