Skip Navigation

[Resolved] Display a specific Layout with a CRED Edit Form, after click on the Edit Link

This thread is resolved. Here is a description of the problem and solution.

Problem:
I have a layout with some content and a CRED Edit Link in that Layout.
The Link should lead to the CRED Edit Form, but I want that Form to be displayed by a single Layout, not within the above mentioned Layout.
This way, i could replace teh ENTIRE template by a specific Layout, that holds only the CRED Form
Can I do that?

Solution:
Yes.

1. Create your specific Layout and add the CRED edit Form in it

2. Copy the ID of that Layout and replace the ID in the code below with it

3. The Code below shoudl go to your theme functions.php

add_filter('get_layout_id_for_render', function($id, $slug){
         
        global $post;
  
        if( null !== $post && $post->post_type === 'WHAT_I_NEED' && isset($_GET['cred-edit-form']) ){
            $id = 'ID_OF_LAYOUT_I_WANT';
        }
        return $id;
} );

==> Replace WHAT_I_NEED with the Post Type Slug
==> Replace ID_OF_LAYOUT_I_WANT with the ID of the Layout with the CRED form

This support ticket is created 7 years, 8 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 23 replies, has 3 voices.

Last updated by Beda 7 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#422854
screenshot of what should be cred edit my profile form but displays post instead.jpg

I am using the Classifieds with Layout reference site as the base for my site

I am trying to: have an 'Edit' link at the bottom of custom post type Member Profile layout so that the author of the profile can go to the Edit My Profile CRED form.

I have replicated the 'Ad Tech Info' functionality from the Ads List and Ad Single layouts that came with the site download and changed the

[cred_link_form form="Edit product" text="Edit" target="_self" class="listing-edit-button"]

to

[cred_link_form form="Edit My Profile" text="Edit target="_self" class="listing-edit-button"]

I visited this URL: hidden link then clicked on Edit at the bottom. The browser went to:

hidden link

I expected to see: the CRED edit form with the user profile already loaded into the fields

Instead, I got: the Member Profile displayed as it had been on the previous page.

I have checked and the same mechanism is working fine with the Listings post type

I have checked in Access and the CRED form 'Edit My Profile' is available for users down to Subscriber level to edit their own post.

I have the same problem whether I am logged in as the site administrator or a subscriber level user with a Member Profile record.

#422871

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand you want to edit user profile. To add Edit profile link you should use CRED shortcode: "cred_link_user_form"

For example:

//Display link for editing user with ID 12 (use form with title "Edit User")
[cred_link_user_form form="Edit User" user="12" text="Edit user"]

//Display link for editing current logged in user (use form with title "Edit User")
[cred_link_user_form form="Edit User" text="Edit user"]

More info:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_link_user_form

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

#422878

Sorry Minesh! This is not a User form I am trying to edit, it is a custom post type called Member Profile.

I wanted to do everything using the User form but as Toolset lacks the functionality to display users at the front end and make them searchable, I instead had to create a CPT called Member Profile and restrict each user to only creating one post in it.

So as far as I can tell my code is correct in that I am calling an edit form that's attached to the CPT being viewed and as per the 'Ad Tech Info' cell in the Single Listing layout that came with the site, I have left the conditional display statement intact i.e. is the person looking at this form either the author or the site administraor. If so, display the option to edit and delete, if not, don't display

#422899

Minesh
Supporter

Languages: English (English )

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

I need to check on your install whats going wrong there.

*** 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.

#422904

Minesh
Supporter

Languages: English (English )

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

Tickets will be automatically closed after 30 days. So if you able to revert back within 30 days with same issue, please report back to this ticket.

OR

You can resolve this ticket and you are free to open a new ticket anytime. 🙂

#422979

I've created a new site and installed the Classifieds reference site again.

I started off by confirming that the form for editing an Ad is working as it should - I go to the list of Ads, click on the 'Edit' link against a record and I'm taken to a new page with the form where I can edit the listing. The URL is that of the advert with the ?cred-edit-form=xxxx at the end.

However when I recreate the same mechanism for my Member Profile CPT now I get a slightly different problem to before - instead of just the post dispaying, I now get the Post Title and Featured image followed by the CRED form instead of just the cred form

In browsing around the various assets that come with the reference site, I noticed that there is a Layout - Ad Single - Edit which contains the CRED form for editing an ad. I wasn't sure if this was in use as when you hover over 'Edit' against an ad, the target URL is the ad URL with the cred edit form at the end

To test, I edited the Ad Single - Edit and inserted a 'Let's see if this is in use' bit of text at the top.

Sure enough when I click on the Edit link of an Ad, this layout is loaded. But I can't see anywhere where this layout is referred to as being what should be used when loading the form to edit an Ad. In my list of layouts it is in the top section - layouts not being used anywhere - yet clearly it is.

#423112

Minesh
Supporter

Languages: English (English )

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

Please find below the process to follow and how it will (and already does) work.

1. CRED Form LINK as a ShortCode is not working in a Content Template if we do NOT call a post body ([wpv-post-body view_template='None']) as well in that same Content Template.

2. The CRED Form Link as a ShortCode in a Visual Editor works perfectly fine, without any call to Post Body, and it is suggested to use the Visual Editor to do this.

3. A view Cell, which queries those posts, and holds the CRED Link as a ShortCode, works as long you do not edit the post to which the layout is assigned (as current viewed post), in other words, the current post.

This means when you uncheck "Don't include current page in query result" in the View, and then visit the current Post styled with Layout, which holds the View Cell, editing the very same post will not work.

This is solved by calling the Post Body in a Content Template Cell in your Layout.

If you do check the option "Don't include current page in query result" in your view, the Current Post will not be available anyway and every other post will be editable through those links.

No post body needs to be called in this case at any place.

4. A View Shortcode (same view as above), Works the same way as described above.

So to conclude, you need either to call the Post Body as well, so CRED can replace it, or, you use the Visual Editor Cell.

Does this help?

#423798

I have read Minesh's reply several times and cannot get my head around it.

I have completely rebuilt my site yet again back to the Classifieds reference site, added my CPT 'Member Profiles' and then once again created a content template called 'Member Profile Tech Info' which is a cut and paste from the 'Ad Tech Info' content template that is installed with the reference site.

My layout to view a Member Profile record has similar cells to the Ad Single layout (post title, some fields, featured image etc) with the Member Profile Tech Info cell at the bottom just like the Ad Tech Info cell in Ad Single layout.

But I am back to my original problem - when I click on Edit, instead of the screen clearing and the edit form being displayed (as it does for when you click on the equivalent link in an advert), I am just looped back round to the record I was viewing with the addition of the CRED form reference appended to the URL.

I just don't understand why, when I've duplicated a working mechanism for the Listings post type, changed the CPT where necessary in the code and called fields from my CPT, the same mechanism isn't working.

#423800

Minesh
Supporter

Languages: English (English )

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

I need to check on your install and need step by step information to reproduce the issue.

*** 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.

#423869

I have just tried setting up another CRED form to edit my content type Member Profile (form ref 5897) using the 'autogenerate form'

When I insert this into a layout (id 5990) then visit the URL

hidden link

the form displays properly

but I replace the 5897 with 5942 (the id of my original form), I don't get the form, I get the Member Profile displayed

I won't do any more until you have taken a look but perhaps regenerating my form might iron out the wrinkles.....

#424163

Minesh
Supporter

Languages: English (English )

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

Yes - I'm on this. I'll get in touch with you as soon as possible.

#424209

A couple of issues have arisen and I want to check whether they are because of something you are doing:

a. I have suddenly started to get an error message while I am trying to edit the Parametric Ad Search view. It appears at the front end where the Search view is included in the home page

Warning: Invalid argument supplied for foreach() in /home/whippetw/public_html/thought4paws.org/wp-content/plugins/cred-frontend-editor/embedded/toolset/toolset-common/lib/enlimbo.forms.class.php on line 708

b. The Edit product CRED form which came as part of the reference site (and is the bit that IS working) has vanished overnight.

#424686

There are 2 Codes in that layout.
One is wrong:

[cred_link_form form="Edit My Profile" text="Edit" target="_self" class="listing-edit-button"]

Please use the CRED Forms button to insert ShortCodes.

To have a Edit Profile CRED form link on that Layout, use this:

Since you display a CRED form in a layout Content Tempalte you need to also call the Post Body, otherwise the CRED Form has nothing to replace.

To do that, I added a Post Body call wrapped in a conditional, so it will show only when you call the CRED Form.
I have done that using the wpv-search-term shortcode.

I added the codes already to your Layout, it looks like this:

[cred_link_form form='5942' form_name='Edit My Profile' text='Edit %TITLE%' target='_self']
  [wpv-conditional if="( '[wpv-search-term param='cred-edit-form']' eq '5942' )"][wpv-post-body view_template='None'][/wpv-conditional]

When you call the CRED form (hidden link) it will work now.

#424772

Hi Beda

It still isn't working properly. The page still displays the member profile record first then the form underneath instead of just the form.

I have the same problem with my Listings editing mechanism as well

🙁

#424773

This is expected, as the CRED form replaces the content, not the layout.

A Layout is replacing the whole thing, from header to footer.

A CRED form replaces the content.

Since you have other elements in this Layout, those will display with the Form.

You can change the position of the form, and you could wrap all other contents in your Cells in the same condition as I did wrap the CRED Form, to hide it when the form is shown

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