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
| Feature | Description |
|---|---|
| Role-Based Button Customization | Define different button labels and links for each WordPress user role. |
| Guest Support | Built-in “Guest (Not logged in)” pseudo-role for visitors who are not authenticated. |
| Multi-Role Selection | Each condition can target multiple user roles simultaneously. |
| Custom Button Labels | Override the button text with any string, including HTML for icons. |
| Custom Button Links | Redirect the button to any URL — internal pages, external sites, or anchor links. |
| Unlimited Conditions | Add as many button conditions as you need via a repeater interface. |
| Priority-Based Matching | Conditions are evaluated in reverse order (last added = highest priority), and the first match wins. |
| No Template Overrides | Works 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:
| Field | Description |
|---|---|
| User Role | A 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 Link | The destination URL for the button. Supports full URLs, relative paths, and anchor links (#). |
| Button Label | The 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:
| Role | Description |
|---|---|
| Guest (Not logged in) | A special option for visitors who are not logged in. This is the most common role to configure. |
| Subscriber | Default WordPress subscriber role. |
| Contributor | Default WordPress contributor role. |
| Author | Default WordPress author role. |
| Editor | Default WordPress editor role. |
| Administrator | Default WordPress administrator role. |
| Custom roles | Any 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.
Button Link Examples
| Value | Use 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:
| Value | Result |
|---|---|
Add Listing | Plain text button. |
Sign Up | Custom CTA text for guests. |
Upgrade Plan | CTA for users who need to upgrade. |
<i class="icon-location-pin-check-2"></i> Add Listing | Button with a MyListing icon and text. |
<i class="icon-plus"></i> Submit Your Business | Icon + 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
| Field | Value |
|---|---|
| User Role | Guest (Not logged in) |
| Button Link | https://example.com/register/ |
| Button Label | Sign 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:
| Field | Value |
|---|---|
| User Role | Subscriber |
| Button Link | https://example.com/pricing/ |
| Button Label | <i class="icon-star"></i> Upgrade |
Condition 2:
| Field | Value |
|---|---|
| User Role | Editor, Administrator |
| Button Link | https://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
| Field | Value |
|---|---|
| User Role | Contributor |
| Button Link | # |
| Button Label | Contact 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
| Cause | Solution |
|---|---|
| No matching condition | Ensure a condition exists that targets the user’s role. Check the User Role multi-select in the condition. |
| Empty link or label | Both the Button Link and Button Label must be filled in. If either is blank, the condition is skipped. |
| A higher-priority condition matched first | Conditions 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 caching | Full-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
| Cause | Solution |
|---|---|
| JavaScript execution timing | The 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
| Cause | Solution |
|---|---|
| JavaScript disabled | The override requires JavaScript to be enabled in the visitor’s browser. This is standard for most modern browsers. |
| MyListing theme updated header structure | The 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 saved | Go 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.