Skip Navigation

[Resolved] Submitting post only one time

This support ticket is created 3 years, 6 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 5.01 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by annaA-2 3 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#2064549

Hi,
I'm following this https://toolset.com/forums/topic/voting-system/ to create a similar voting system in my website and it works fine.

But then I tried to follow this https://toolset.com/forums/topic/logged-in-users-can-submit-the-form-and-create-content-only-one-time/ to limit vote 1 time for user.

But after I did it my post layout crashed.

I did it another time but I don't want to repeat the crash 🙂 how can I do?

Thank you!

#2064887

UPDATE:

I did everything 3 times and I noticed that when I add the create post form in any kind of page (WordPress page, content template) after I save it the page crashes and I can't reopen it.

I don't know if the function I tried to add before caused a permanent problem in my website or if the form plugin has some bug.

I need you to take a look at it.

Thank you so much,
Anna,

#2065079

Hello Anna and thank you for contacting the Toolset support.

The crash is most likely coming from a code error. Activate PHP debugging by following this article's section. Try to reproduce the issue to trigger errors. Then check the errors file, by reading the error you will likely find out the cause of the issue.(maybe you have declared a function twice, or you have omitted a ";" symbol at the end of a line, etc.)
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#php-debugging

Please note that custom code is beyond the scope of the support. I am willing to check it and give it a quick try, but if it needs advanced customization, you will need to hire a developer.
- https://toolset.com/toolset-support-policy/
- https://toolset.com/contractors/

Your next reply will be private to let you share credentials safely. Please add FTP access too, and let me know where did you add the custom code. ** Make a database backup before sharing credentials. **

#2066405

Hi, thank you.
It was a php memory limit problem.

Now I'm trying to add this function to allow user to vote only one time for a post.

function u_post_count() {
$user_post_count = count( get_posts( array(
'post_type' => 'valutazione-sogg',
'author' => get_current_user_id(),
) ) );

return $user_post_count;
}

I followed Beda instructions and I added u_post_count in conditional frontend contend and conditional field in my form page.

But now users can vote one time but only for one post. I need they can vote also other posts.

I created a relationship between post (parent) and votes (child).

How can I add a "parent" control to this function? I think it should check user ID and also parent post ID.

Could you help me to add it?

Thank you in advance!

#2066623

As you may know, get_posts function uses an instance of WP_Query under the ground, you will need to add the toolset_relationships argument to the query. Please check this article:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/

Or you can use the toolset_get_related_posts from the Toolset relationship API, instead of the get_posts function. https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

#2067213

Problem is not resolved