Remove the "Edit Form" link - Code Parrots

Knowledge Base

Remove the “Edit Form” link

Article Last Updated: March 4, 2021

You may notice forms have a link below them with the text “Edit Form”, as seen in the above screenshot.

This text will only be visible under the following conditions:

  1. The user viewing the page is logged into the WordPress site
  2. The user viewing the page has the manage_options capability

Note: you can change the manage_options capability to any capability you’d like using the following filter: yikes-mailchimp-user-role-access. If you’re using this filter, make sure you’re using a valid role/capability that can be passed into the current_user_can() function.

If you’d still like to remove this link (for example, maybe you want to view your form exactly as a user would), you can use the filter yikes-mailchimp-front-end-action-links.

Filter: yikes-mailchimp-front-end-action-links

Parameters:

  1. $edit_form_link – the HTML comprising the edit form link
  2. $form_id – the ID of the current form
  3. $form_title – the title of the current form

Example:

function yikes_mailchimp_remove_action_links( $edit_link_html, $form_id, $form_name ) {
    return '';
}

add_filter( 'yikes-mailchimp-front-end-form-action-links', 'yikes_mailchimp_remove_action_links', 99999, 3 );

The above code snippet will remove the action link in all cases. However, we provide the $form_id so it’s quite simple to run conditional logic based on the form.

Note: if you have the Customizer extension installed, this code will remove the “Customize Form” link.