Skip Navigation

[Resuelto] How do I choose which record to edit in edit form

This support ticket is created hace 5 años, 9 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 9 respuestas, tiene 2 mensajes.

Última actualización por Minesh hace 5 años, 9 meses.

Asistido por: Minesh.

Autor
Mensajes
#1201439

I have a CPT 'User Will' and I want to go to a new page with an edit form to edit 'User Will' however I want to edit a the first User Will record belonging to that particular logged-in user...How can I achieve this please

#1201619

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - when you say the first 'User Will' you want to edit - is there any identification that XYZ is the first "USER WILL" belongs to logged in user or there will be only one 'User Will' belongs to each loggedin user?

#1201660

Hi Minesh...Good to hear from you...hope you're well...

Yes I have built the site so the user can only create 1 'USER WILL' CPT so I need to go to a new page or template and edit their User Will record

Hope that makes sense...

At the minute the only way I can edit the USER WILL record is via the page of that particular post... The other way is by creating a view list with the record in the list and an edit link next to it..

Best regards

G

#1201667

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

But what is the way to identify that this "User WILL" belongs to the loggein user? Did you set the logggedin user as the "User WILL" post author so we can identify that this "User WILL" belongs to this user?

Can you also tell me where exactly you want to add the Edit form - on which page? Did you created the "User WILL" edit form?

*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

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

#1201668

I just find the first record of CPT 'User Will' that belongs to (is the author) the current logged in user

#1201669

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Great - so that means we have a way to find the "User WILL" based on the loggedin user.

Now, Can you also tell me where exactly you want to add the Edit form - on which page? Did you created the "User WILL" edit form?

#1201671

Yes exactly...So the logged in user can only create one User Will and it can be found by 1st record of CPT created by current logged in user..

So I have created a page 'section-complete' and on that page I have a CRED form to edit the User will CPT..I just need it to edit the logged in users CPT

Thanks Minesh

#1201705

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

OK - you should try to add the following code to your current theme's functions.php file:

function func_display_will_edit_form() {
  $args = array(
    'post_type'      => 'post-type-slug',
    'author'         => get_current_user_id(),
    'status'         => 'publish',
    'posts_per_page' => -1,
    'fields'=>'ids'
    );
$user_will = get_posts( $args );
return $user_will[0];
}
add_shortcode('display_will_edit_form', 'func_display_will_edit_form'); 

Where:
- Replace 'post-type-slug' with your CPT 'User WILL' slug

Then,
Register the shortcoede "display_will_edit_form" at:
=> Toolset => Settings => Front-end Content => Third-party shortcode arguments

Now, add the form shortcode to your page as given under:

[cred_form form='your-edit-form-slug' post='[display_will_edit_form]']

Where:
- Replace 'your-edit-form-slug' with your original edit form slug.

I think above solution will help you to resolve your issue.

#1202059

Thank you Minesh

That's great and seems to be working...the final part of my problem is to redirect to the User Will post page after submitting the form... The form only allows me to redirect to specific named pages rather than the unique dynamic url e.g. your domain.com/user-will/my-user-will

Many thanks Minesh...nearly there

G

Los hilos nuevos creados por Minesh y vinculados a este se encuentran a continuación:

https://toolset.com/es/forums/topic/split-how-do-i-choose-which-record-to-edit-in-edit-form-redirect-after-submit/

#1202271

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Glad to know that the solution I shared help you to resolve your issue. I split the ticket with your new question.

This will help other users searching on the forum as well as help us to write correct resolution summary to which support request originally belongs to. Please feel free to close this ticket and we will continue with the split ticket.