Skip Navigation

[Resolved] modify permalink

This support ticket is created 4 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
- 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 edr-2 4 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1657633
permalink-slug.png

Tell us what you are trying to do? the normal permalink would be domain.com/attorney/firstname-lastname
but its turned into ( see pic )

Is there any documentation that you are following? well various notes and articles

Is there a similar example that we can see?
hidden link

What is the link to your site? hidden link

#1658049

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand, you are using a Toolset form that will allow user to submit the new entry for the post type "attorney" from the frontend.

And you want to change the post slug for the submitted entry as: attorney/firstname-lastname
- correct?

Please correct me if I do not understand your issue correctly.

#1658555

Hi Minehs, i think you understand correctly. When the post from the cred is published, it has normally a permalink such as
hidden link
charles is a first name and triay is a last name.
In order to determine if there is some problem with the form itself here in full is what i have in the form
"New Attorney"
this is the full content of the CRED
I am wondering if there is something wrong with it, because it used to work ok
( on the production site), but perhaps in rewriting it a bit has gone wrong?
or is there some plugin that might be interfering?
i will give credentials if needed, and also today i will deactivate plugins and see if one is interfering.

[credform class="cred-form cred-keep-original"]

[cred_field field="form_messages" value=""]
<div class="cred-field cred-field-post_title">
<label class="cred-label">
Attorney Name (Required)
</label>
[cred_field scaffold_field_id='lawyer-name' field='lawyer-name' force_type='field' required="true" class='form-control' output='bootstrap' label='Lawyer Name']
</div>

<br>
Breadcrumb (not required)<br>
[cred_field scaffold_field_id='breadcrumb' field='breadcrumb' force_type='field' class='form-control' output='bootstrap' label='breadcrumb']
<br>
<label class="cred-label">
Upload photo ( not required )<br>
Please try to upload a photo of the proper dimensions (100px by 150px)<br>
</label>
[cred_field scaffold_field_id='attorney-photo' field='attorney-photo' force_type='field' class='form-control' output='bootstrap' label='Attorney Photo']

<br>
<label class="cred-label">
Law Firm*
</label>
[cred_field scaffold_field_id='law-firm' field='law-firm' force_type='field' class='form-control' output='bootstrap' label='Law Firm' required="true"]

<br>
<label class="cred-label">
Address*
</label>
[cred_field scaffold_field_id='address' field='address' force_type='field' required="true" class='form-control' output='bootstrap' label='Address']

<br>
<label class="cred-label">
Phone*
</label>
[cred_field scaffold_field_id='phone' field='phone' force_type='field' class='form-control' required="true" output='bootstrap' label='Phone']

<br>
<label class="cred-label">
Website*
</label>
[cred_field scaffold_field_id='website' field='website' force_type='field' class='form-control' output='bootstrap' required="true" label='Website']

<br>
<label class="cred-label">
Email*
</label>
[cred_field scaffold_field_id='email' field='email' force_type='field' class='form-control' required="true" output='bootstrap' label='Email']

<br>
<label class="cred-label">
Bar Admissions State*
</label>
[cred_field scaffold_field_id='bar-admissions-state' field='bar-admissions-state' force_type='field' required="true" class='form-control' output='bootstrap' label='Bar Admissions State']

<br>
<label class="cred-label">
Bar Admissions Year*
</label>
[cred_field scaffold_field_id='bar-admissions-year' field='bar-admissions-year' force_type='field' class='form-control' output='bootstrap' required='true' label='Bar admissions year']
<br>
<label class="cred-label">
Bar Number*
</label>
[cred_field scaffold_field_id='bar-number' field='bar-number' force_type='field' class='form-control' required="true" output='bootstrap' label='Bar number']

<br>
<label class="cred-label">
Law Degree*
</label>

[cred_field scaffold_field_id='law-degree' field='law-degree' force_type='field' class='form-control' output='bootstrap' label='Law Degree' required="true"]

<br>
<label class="cred-label">
State License*
</label>
[cred_field scaffold_field_id='state-license' field='state-license' force_type='field' class='form-control' output='bootstrap' label='State License' required="true"]

<br>
<label class="cred-label">
Zip Code*
</label>

[cred_field scaffold_field_id='zipcode' field='zipcode' force_type='field' class='form-control' output='bootstrap' required="true" label='zipcode']

<br>
<label class="cred-label">
Lawyer Services*
</label>
[cred_field scaffold_field_id='lawyerservices' field='lawyerservices' force_type='field' class='form-control' output='bootstrap' label='LawyerServices']

<br>
[cred_show_group if="($(email) eq '1')" mode="fade-slide"]
<label class="cred-label">
[/cred_show_group]

<br>
<br>
Select Both State and County *
</label>

<div class="boxes"];
[cred_field scaffold_field_id='statecounty' field='statecounty' force_type='taxonomy' output='bootstrap' display='checkbox' required="true" label='State and County']
</div>
<br>
Miscellany <br>
County bar association memberships
[cred_field scaffold_field_id='county-bar-association-memberships' field='county-bar-association-memberships' force_type='field' class='form-control' output='bootstrap' label='County bar association memberships']
Professional org memberships
[cred_field scaffold_field_id='professional-org-memberships' field='professional-org-memberships' force_type='field' class='form-control' output='bootstrap' label='Professional org memberships']
Undergrad degree
[cred_field scaffold_field_id='undergrad-degree' field='undergrad-degree' force_type='field' class='form-control' output='bootstrap' label='Undergrad degree']
Grad degree
[cred_field scaffold_field_id='grad-degree' field='grad-degree' force_type='field' class='form-control' output='bootstrap' label='Grad degree']
Number of attorneys in Office
[cred_field scaffold_field_id='num-of-attorneys' field='num-of-attorneys' force_type='field' class='form-control' output='bootstrap' label='Num of attorneys']
Previous employment
[cred_field scaffold_field_id='previous-employment' field='previous-employment' force_type='field' class='form-control' output='bootstrap' label='Previous employment']
Activities and Awards
[cred_field scaffold_field_id='activities-and-awards' field='activities-and-awards' force_type='field' class='form-control' output='bootstrap' label='Activities and Awards']
Testimonials
[cred_field scaffold_field_id='testimonials' field='testimonials' force_type='field' class='form-control' output='bootstrap' label='Testimonials']

[cred_field field="form_submit" value="Submit" urlparam=""]

[/credform]

#1658615

Minesh
Supporter

Languages: English (English )

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

Yes - can you please run compatibility test first and check.

Such post name rewrite should be done using the "cred_save_data" hook. Have you used that hook?

If no, can you please share problem URL where you added the form as well as access details.

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

#1658625

actually the more i think about it i would want to try to get the permalink to account for
the state and county, since just the attorney name could cause a conflict.
so ideally the permalink should be dmain/state/county/firstname-lastname
right now when you click on a state from the home page and drill down there you will see
the view name is part of the permalink, when you are at the county level it is something like
hidden link
then when you click on an attorney name there you get the slug
so somehow i would want to incorporate that view permalink
hope that makes sense.

#1659065
notitle.png

the current code, as of this moment is
//Create a dynamic post title by the CRED form.
add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {
if ($form_data['id']==1166) {
$name = get_post_meta($post_id, 'wpcf-lawyer-name', true);

$title= $name;
// $title = get_the_title($post_id);
// $slug = sanitize_title($post_title);
$slug = sanitize_title($title);
// $args = array('ID' => $post_id, 'post_title' => $title);
// print_r ( $title);
//wp_update_post($args);
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
}
}

which produces an empty title, but no auto draft permalink.
ideally it would also have a state and a county prepending what is there now...
i saw no privacy notice so i cannot send creds in this note.

#1659771

Minesh
Supporter

Languages: English (English )

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

There are two different things you mentioned.

1) so ideally the permalink should be dmain/state/county/firstname-lastname
- There are no rewire rules added using Toolset. If you want such pretty permalink, you need to add rewrite rules or using any of available third party plugin to rewrite your URL.

2) As you shared information with your last reply: https://toolset.com/forums/topic/modify-permalink/#post-1659065
- Using cred_save_data hook, you can change the post_name (post slug).

So, can you please confirm what solution you are looking for. If you want #1, there is no native feature available with Toolset, as I mentioned you need to use third-party plugin or add rewrite rules on your own. If you need help with #2, please let me know and share information what post name(post slug) you want to add as per your requirement.

#1660463

a recent discovery is that if i changed the form a bit i could avoid the auto draft problem ie;
i modified the top portion of the form to look like this:
[credform]
[cred_field field='form_messages' class='alert alert-warning']
<div class="form-group ">
<label>Suggested Attorney Title: State County First and Last Name</label>
[cred_field field='post_title' class='form-control' output='bootstrap']
</div>
it seems required,
once i did that the title/permalink could be created by the user.
wondering how the form title became required now.
i removed all the function code i had added and it worked fine.
i would like to know though how to update the forms title
ie field='post_title'
before the form is saved,
and use the values that would be on the form before submitting.
so if i had on the form State and another field County, how to update the post_title with those fields.

#1660635

My issue is resolved now. Thank you!