Skip Navigation

[Resolved] Post edit form count

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by Minesh 7 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2690504

I created a multi-step form so that the first form is posting a post and the second and third forms are post editing forms
First of all, I prepare a button so that it is possible to access the previous form,
So for the first step that has the post publication form I made a function that returns if it has such a post type and I made two Conditional
And in one of the conditions I determined that if he doesn't have the post, he will see a post publication form,
And in the second condition I determined that if he has the post he will display a post editing form
But for the next steps, because it's a post edit form and it's not a post that the function can return if it has such a post, I don't know what to do to make the function return a value if it has such a form
Thanks
Younes

#2690657

Below is the function that returns a number of posts by post type
What do I write that the function (instead of 'post_type' => 'yonas', ) will return if the logged in user has data in the post editing form or not
To know whether to show him an empty post editing form or a post editing form with his data

function u_post_count() {

$user_post_count = count( get_posts( array(

'post_type' => 'yonas',

'author' => get_current_user_id(),
) ) );

return $user_post_count;
}

Thank you
Younes

#2690659

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Are you using conditional block or conditional shortcode?

I need to know how you configured your steps? are you passing the post ID as URL param?

If you can share problem URL and admin access details and explain me the flow I will review your current setup and after that I will be able to guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2690739

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing admin access details but the shared admin access details not working at this end.

Can you please share working admin access details.

I have set the next reply to private which means only you and I have access to it.

#2690885

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When I try to access the content template listing page I see blank page - Can you please check what happens there?
- hidden link

What if you try to add different step form in different page and pass the post ID as URL param - will that work for you?

As I do not able to access the content template - I'm not sure how exactly you added the form to content template? Have you added using form shortcode or form block?

To display edit form for specific post ID you can use the Toolset Form shortcode:

[cred_form form="99999" post="1111"]

Where:
- Replace 99999 with your original form ID
- Replace 1111 with the actual edit post ID you want to edit. You may try to get edit post ID using URL param or using custom shortcode. If you use custom shortcode dont forget to register it at:
=> Toolset => Setting => Front-end Content => Third-party shortcode arguments

More info:
- https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_form

#2690892
u_post_count.JPG

The link to the template is this hidden link
Because I want to make a button first, I need to have an edit form inside a view with a filter of the connected user so that when he goes to the previous form he will see the details he entered
So I need to put an edit form inside a view with a user filter attached and another form without a view with a filter
And so that the first form does not appear, when the second form appears (which is displayed) to the user with his details, I want to make a conditional block, and determine that if the u_post_count function returns above 0, the first form will not appear
!!! What I don't know is what to write in the array in the u_post_count function !!!!
Look at the picture I'm attaching, I don't know what to write instead ('post_type' => 'yonas')

I know I'm not professional and I'm not clear enough, I'd appreciate some help

#2691108

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Is there any reason that you set the permalink to option: שנה, חודש, יום ומזהה הפוסט
- hidden link

If no - you should set the permalink to option "מזהה הפוסט" and save it.

Now, using what frontend user we have to login?

On what page you added the following content template?
- hidden link

Lets say - I'm a new user just visiting the site on what page I will see the first step form? on the following page - right?
- hidden link

If yes - using what user access detail I should login? when I checked the following page as not logged in user:
- hidden link

I see only the login page. Here when user is not logged in do you want any form to register user? If yes what form?
OR
using what access details I should login as frontend user?

#2691208

1) I set the permalink to the "מזהה הפוסט" option and saved it.
2)As you wrote, I added the template on the page
- hidden link -%d7%9e%d7%aa%d7%9b%d7%a0%d7%aa/
3) Log in using the registration form on the page
In the first line with an email and in the second line with a password or phone
4) When the user clicks next, it goes through the forms in order (2731, 2733, 2735, 2737)
And the forms are in templates (3040, 2744, 2746, 2745,)
And I added in the forms
<!-- wp:button -->
<div class="wp-block-button">hidden link template-id=2744">previous</div>
<!-- /wp:button -->  
so that the user can click back to return to the previous form, but when the user returns, the previous form should contain the information the user has already entered
Thank you
Younes

#2691461

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As it was really challenging task to work on you site - I've to setup a demo site.

Here is a sandbox site and you can auto-login to it using the following link:
- hidden link

As you can see I've created the custom role "Programmer":
- hidden link

Created User form "Add new programmer user" to register user:
- hidden link

Created all the post form for step 1,2 and 3:
- hidden link

Here is the page from where you can start registering:
- hidden link

As soon as you will register, it will redirect you on the following page:
- hidden link

As you can see in backend:
- hidden link
Where:
- under first conditional block I've added the post add form to add new book post
- under second conditional block I've added the edit post form to edit the existing post

[cred_form form='edit-book-step-1' post='[get_edit_post_id]']

And to get the edit post ID we use the custom shortcode: [get_edit_post_id]
- The custom shortcode is added to "Custom Code" section:
=> hidden link

add_shortcode('get_edit_post_id','func_get_edit_post_id');
function func_get_edit_post_id() {

$user_post = get_posts( array(

'post_type' => 'book',

'author' => get_current_user_id()
)) ;

$user_post_count = count($user_post);
  
 if($user_post_count){
    	return $user_post[0]->ID;
 }else{
    return 0;

  }
}

Also we register the custom shortcode name at: Third-party shortcode arguments
- hidden link

This is how the previous link is setup on "Edit book step 2" form:
=> hidden link

<div class="col-sm-4">
			<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="/add-new-book">previous</a></div>
<!-- /wp:button -->

I hope this will get you the idea about how you can add previous button and get edit post id.