{CODICTS} Snippets is now available

MyListing Add Listing Button Conditions

The {CODICTS} MyListing Add Listing Button Conditions plugin lets you dynamically change the “Add Listing” button in the MyListing header based on the current user’s WordPress role. Define different button labels and destination URLs for different roles — redirect guests to a registration page, subscribers to a pricing page, and business owners to the listing form, all from a simple settings page.

No child theme required: This plugin does not require a child theme. It works via JavaScript DOM manipulation without modifying any theme template files.

Installation & Activation

Start by downloading the plugin from the Downloads page on your dashboard on the CoDicts website.

After downloading, install and activate the plugin in WordPress by navigating to “Plugins” > “Add New” > “Upload Plugin” and selecting the downloaded zip file. Click “Install Now” and then “Activate”.

After activation, a new “Add Listing Button Conditions” menu item appears in the WordPress admin sidebar. You can also access the settings via the “Settings” link on the plugin’s row in the Plugins list.

Note: If the MyListing theme is not detected, an admin error notice is shown and the plugin’s functionality is disabled.


Key Features

FeatureDescription
Role-Based Button CustomizationDefine different button labels and links for each WordPress user role.
Guest SupportBuilt-in “Guest (Not logged in)” pseudo-role for visitors who are not authenticated.
Multi-Role SelectionEach condition can target multiple user roles simultaneously.
Custom Button LabelsOverride the button text with any string, including HTML for icons.
Custom Button LinksRedirect the button to any URL — internal pages, external sites, or anchor links.
Unlimited ConditionsAdd as many button conditions as you need via a repeater interface.
Priority-Based MatchingConditions are evaluated in reverse order (last added = highest priority), and the first match wins.
No Template OverridesWorks entirely via JavaScript — no theme files are modified.

How It Works

By default, MyListing displays a single “Add Listing” button in the site header that links to the listing submission page. This plugin overrides that button based on who is viewing the site:

1. You create button conditions on the settings page — each condition specifies which user roles it applies to, what the button should say, and where it should link.

2. When someone visits your site, the plugin checks their WordPress role against your conditions.

3. If a matching condition is found, the button’s text and link are replaced. If no condition matches, the default MyListing button remains unchanged.

Both the desktop and mobile header buttons are updated simultaneously.


Settings Page

After activation, navigate to “Add Listing Button Conditions” in the WordPress admin sidebar.

The settings page uses a repeater interface where each row represents a single button condition. Each condition has three fields:

FieldDescription
User RoleA multi-select dropdown with all WordPress roles plus a “Guest (Not logged in)” option. Select one or more roles that this condition applies to.
Button LinkThe destination URL for the button. Supports full URLs, relative paths, and anchor links (#).
Button LabelThe text displayed on the button. Supports raw HTML for including icons.

Adding a Button Condition

1. Navigate to the Add Listing Button Conditions settings page.

2. Click the “Add a Button Condition” button at the bottom.

3. A new accordion row appears. Click the chevron (▼) on the right to expand it.

4. Configure the three fields:

User Role: Select one or more roles from the dropdown.

Button Link: Enter the destination URL.

Button Label: Enter the button text.

5. Click “Save Changes”.

Add as many conditions as you need by repeating these steps. Each condition appears as a collapsible accordion row showing the assigned roles in the header for quick identification.


Available User Roles

The User Role dropdown includes all registered WordPress roles:

RoleDescription
Guest (Not logged in)A special option for visitors who are not logged in. This is the most common role to configure.
SubscriberDefault WordPress subscriber role.
ContributorDefault WordPress contributor role.
AuthorDefault WordPress author role.
EditorDefault WordPress editor role.
AdministratorDefault WordPress administrator role.
Custom rolesAny additional roles registered by other plugins (e.g., WooCommerce’s “Customer” or “Shop Manager”).

You can select multiple roles per condition. The condition matches if the current user has any of the selected roles.


ValueUse Case
https://example.com/pricing/Redirect to a pricing page.
https://example.com/register/Redirect to a registration page.
https://example.com/add-listing/Keep the default add listing page.
/my-account/Relative URL to an internal page.
#Makes the button a no-op anchor (useful with custom JavaScript to trigger a modal).

Button Label Examples

The label field supports raw HTML, allowing you to include MyListing icons or other inline markup:

ValueResult
Add ListingPlain text button.
Sign UpCustom CTA text for guests.
Upgrade PlanCTA for users who need to upgrade.
<i class="icon-location-pin-check-2"></i> Add ListingButton with a MyListing icon and text.
<i class="icon-plus"></i> Submit Your BusinessIcon + custom text.

Condition Priority & Matching Order

When multiple conditions exist, the plugin evaluates them in reverse order — the last condition in the list has the highest priority. The first match wins and all remaining conditions are skipped.

Example:

Condition 1: Subscriber → /pricing/       ("Upgrade Plan")
Condition 2: Guest      → /register/      ("Sign Up")
Condition 3: Editor     → /add-listing/   ("Add Listing")

Evaluation order: Condition 3 → Condition 2 → Condition 1

For a Guest user:
  → Check Condition 3 (Editor) — No match
  → Check Condition 2 (Guest)  — MATCH → Button becomes "Sign Up" linking to /register/
  → Condition 1 is never checked

Tip: Place your most specific or highest-priority conditions at the bottom of the list, since they are evaluated first.


Practical Examples

Example 1: Redirect Guests to Registration

FieldValue
User RoleGuest (Not logged in)
Button Linkhttps://example.com/register/
Button LabelSign Up

Result: Visitors who are not logged in see a “Sign Up” button that links to the registration page instead of the default “Add Listing.”

Example 2: Different Buttons for Subscribers vs. Editors

Condition 1:

FieldValue
User RoleSubscriber
Button Linkhttps://example.com/pricing/
Button Label<i class="icon-star"></i> Upgrade

Condition 2:

FieldValue
User RoleEditor, Administrator
Button Linkhttps://example.com/add-listing/
Button Label<i class="icon-location-pin-check-2"></i> Add Listing

Result: Subscribers see an “Upgrade” button with a star icon linking to pricing. Editors and Administrators see the standard “Add Listing” button with an icon.

Example 3: Disable Navigation for a Specific Role

FieldValue
User RoleContributor
Button Link#
Button LabelContact Us

Result: Contributors see a “Contact Us” button that doesn’t navigate anywhere. You could combine this with custom JavaScript to trigger a contact modal.


Frequently Asked Questions

Do I need a child theme?

No. This plugin works entirely via JavaScript DOM manipulation and does not require a child theme or modify any theme files.

Can I target users who are not logged in?

Yes. The plugin includes a built-in “Guest (Not logged in)” option in the user role dropdown that matches all visitors who are not authenticated.

Can I assign multiple roles to one condition?

Yes. The user role field supports multi-select. Select as many roles as you want — the condition matches if the user has any of the selected roles.

Can I use HTML in the button label?

Yes. The label field accepts raw HTML. You can include MyListing icons (e.g., <i class="icon-location-pin-check-2"></i>), Font Awesome icons, or any other inline HTML.

What happens if no conditions match the current user?

The default MyListing “Add Listing” button remains unchanged. The plugin only modifies the button when a matching condition is found with both a link and label set.

What happens if I have no conditions configured?

The plugin does nothing. The default MyListing button appears as normal.

Which condition takes priority if multiple conditions could match?

Conditions are evaluated in reverse order (last added = highest priority). The first match in reverse order is applied. Place your highest-priority conditions at the bottom of the list.

What if a user has multiple WordPress roles?

If a user has multiple roles and multiple conditions match different roles, the last matching condition (in reverse order) wins. The plugin checks if there is any overlap between the user’s roles and the condition’s target roles.

Can I use anchor links (#) as the button link?

Yes. The link field accepts # anchor links. This is useful if you want to disable navigation or use custom JavaScript to trigger a modal or other action on click.

Does both the link and label need to be filled in?

Yes. A condition is only applied if both the link and label are non-empty. If either field is left blank, the condition is skipped and the default button remains.

Does this work on both desktop and mobile?

Yes. The plugin targets both the desktop header button and the mobile navigation button simultaneously, so the override is consistent across all screen sizes.

Does this affect every page on the site?

Yes. The button override applies globally to all frontend pages. There is no option to limit it to specific pages.


Troubleshooting

Button Not Changing for a Specific Role

CauseSolution
No matching conditionEnsure a condition exists that targets the user’s role. Check the User Role multi-select in the condition.
Empty link or labelBoth the Button Link and Button Label must be filled in. If either is blank, the condition is skipped.
A higher-priority condition matched firstConditions are evaluated in reverse order (bottom = highest priority). Check if another condition further down the list matched before the intended one. Reorder conditions if needed.
Page cachingFull-page caching may serve a cached version with the wrong button. Clear your cache or configure your caching plugin to handle user-role-based variations.

Brief Flash of Original Button Before Override

CauseSolution
JavaScript execution timingThe button override runs after the page loads via JavaScript, so the default button may briefly appear. This is a normal behavior of the DOM manipulation approach. For most visitors, the flash is imperceptible.

Button Override Not Working at All

CauseSolution
JavaScript disabledThe override requires JavaScript to be enabled in the visitor’s browser. This is standard for most modern browsers.
MyListing theme updated header structureThe plugin targets specific CSS selectors in MyListing’s header. If MyListing significantly changes its header markup in a future update, the selectors may not match. Contact CoDicts support for an updated version.
No conditions savedGo to the settings page and verify conditions exist and are saved. Check that each condition has all three fields filled in.

“MyListing Theme Not Detected” Error

The MyListing theme must be installed and active. Go to Appearance → Themes to verify.


For further support, visit codicts.com or contact us at support@codicts.com.

CoDicts Co., Ltd. © 2021-2026. All rights reserved