How to change the button text: "Create New Listing" and more...

1) How can I change the button text: "Create New Listing" and the "No Listings" text?
2) Can this change be permanent to remain unaffected by Directory plugin updates?
3) How can I make it so a user can ONLY make ONE listing?
4) Can this change be permanent to remain unaffected by Directory plugin updates?

  • Patrick

    Hi there @Don

    I hope you're having a great day!

    Yes, you can customize any text string in any plugin by creating a custom language file to use for that plugin. The easiest tool to use for that (at least, I think so) is PoEdit:
    http://poedit.net

    Using PoEdit, you simply click the button to create a new translation. Then open the .po or .pot file you'll find in the plugin's languages folder that you would have previously downloaded to your computer.

    Customize any/all text strings in the plugin to your heart's content, then click Save. PoEdit will automatically create the .po & .mo files you need with your custom text strings in it.

    You'll need to edit the filenames to be sure they have the correct text-domain in 'em. That's what identifies the language file as belonging to that specific plugin. You'll find the text-domain listed at the top if the main plugin file. For the Directory plugin, it's in directory/loader.php and you can see that it is
    dr_text_domain

    So custom language files for the Directory plugin would be named like this for example, if your site is in US English:

    dr_text_domain-en_US.po
    dr_text_domain-en_US.mo

    You would then upload those files via FTP to your wp-content/languages/plugins folder (if that folder does not yet exist, simply create it).

    You'll then see your changes on your site, and they will not be affected by any plugin updates unless you manually update those files.

    As for limiting users to only one listing, that is currently not a built-in feature of the plugin. You can, however, enable the credit system in the plugin. Set the cost of a listing to "x" number of credits and grant new users that many credits when they signup. You could then charge them for additional credits to publish additional listings (easy monetization). Would that work for you?

  • Don

    Patrick,

    Thanks for a speedy & thorough reply!

    Poedit is fantastic and did the job; it goes into my must-have tools collection - thank you!

    Directory credits system does not limit a user from creating more listings in my situation. Here's what I did:

    Directory>Settings>Use Credits
    Enable Credits: ON
    Cost Per Credit: 0.99
    Credits Per Listing: 1
    Signup Credits: 1

    I also tried the plugin: Bainternet Post Creation Limits
    It did not work either.

    I welcome any further suggestions...I'm out of ideas.
    Support Access is ON.

    Thanks,
    Don

  • Don

    Hi Sajid,

    Thanks for your reply!

    Yes, I have tried Bainternet-Posts-Creation-Limits and I have the same problem:
    A user can still attempt to create a new listing and when they save it, Directory saves it as a draft.

    What I want is after a user creates a listing, then Directory either no longer shows the create listing button - or - simply does not allow the user to save an additional listing.

    I have tried limiting the user to one listing by setting Directory to use credits only and then setting it so a user gets 1 credit at signup and it costs 1 credit to create a listing.

    I have also tried the Bainternet plugin.

    Both processes allow the user to create a new listing, but saves it as a draft.

    Thanks,
    Don

  • Sajid

    Hi @Don

    Hope you are donig good today :slight_smile:

    Add below code in functions.php file of your child theme or use mu-plugin.

    function wpmu_remove_create_button(){
    	//Allo admin to create unlimited ads
    	if(current_user_can('administrator')) return;
    
    	$user_ID = get_current_user_id();
    	$cup_count = count_user_posts( $userid , $post_type = 'directory_listing' );
    
    	if( $cup_count >= 1){
    		echo '<style type="text/css">.dr_button.add_listing_btn{ display:none; }';
    	}
    
    }
    add_action('wp_footer', 'wpmu_remove_create_button',10);

    This will remove create listings button if a user (except admin) have more than one director listing.

    Take care and have a nice day :slight_smile:

    Cheers, Sajid

  • Don

    Sajid,

    Thanks again for your help! While the code you gave me has fixed the button issue, unfortunately, the code is causing a formatting issue in the Support System plugin. Here's what I've done:

    For diagnostics I have followed the WPMU DEV troubleshooting diagram.

    I changed themes to WP 2015 theme.
    I deactivated all plugins and then turned them back on one at a time until the problem resurfaced.

    PROBLEM
    Issue surfaces when using the plugins: Support System, Directory, and the mu plugin made with the code you gave me.

    With the mu plugin active, and...
    in Support System, if "Use Support System styles" is switched ON, and...
    in Directory, if a listing has been published, then...

    the formatting of the support tickets form & FAQ accordion fails and appears as if "Use Support System styles" is switched OFF.

    BUT

    If either...

    With the mu plugin active, and...
    In Support System, if "Use Support System styles" is switched ON, and...
    in Directory, if a listing is a draft (not published) OR no listing has been made, then...

    the formatting of the support tickets form & FAQ accordion appear fine.

    OR

    if I remove the mu plugin, the support tickets form & FAQ accordion appear fine.

    What to do?
    Support Access is ON.

    Thanks,
    Don

  • Don

    Sajid,

    I may not need your help now but would definitely appreciate your comment on what I think I created as a solution, as I am not a programmer.

    Previously we had:
    add_action('wp_footer', 'wpmu_remove_create_button',10);

    I changed it to:
    add_action('wp_footer', 'wpmu_remove_create_button',100);

    and the problem appears to be resolved.

    Is this a suitable solution?

    Thanks,
    Don

  • Michael Bissett

    Hey @Don, jumping in for Sajid here. :slight_smile:

    Previously we had:
    add_action('wp_footer', 'wpmu_remove_create_button',10);

    I changed it to:
    add_action('wp_footer', 'wpmu_remove_create_button',100);

    and the problem appears to be resolved.

    Is this a suitable solution?

    That's just fine, all you're doing is adjusting when that function of yours is going to be executed (as you're setting the priority for the action call; a lower number means that it'll run sooner, whereas a higher number means that it'll run later). :slight_smile:

    Kind Regards,
    Michael