Character limit for CustomPress => Custom Fields Stopped Working

I had this working in September but for some reason it has stopped working. @Vinod Dalvi provided me with the solution and I have been trying to get an update for why this has stopped working.

Can someone please help me get this working again?

Thanks,
William

  • Rupok
    • Support Ninja

    Hi William

    Hope you had a wonderful day.

    I just tested the solution Vinod provided and it's still working with the latest version of WordPress and CustomPress in my test site. So there must be something on your site which is causing this.

    Can you remember any event after which is stopped working? e.g. updating WordPress, Installing/Updating any plugin? Can you do a plugin conflict test just to make sure no other plugin is causing this? To know more about plugin conflict test, you can visit this article here: https://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/

    Have a nice day. Cheers!
    Rupok

  • William
    • Syntax Hero

    Hi @Rupok

    I ran a plugin conflict test and changed my theme to twenty-sixteen. I am still getting the problem. Can we trouble shoot this another way? I don't remember any major update recently that would have caused this to stop working.

    Support access is granted.

    Thanks,
    William

  • Rupok
    • Support Ninja

    Hi William

    Hope you had a wonderful day.

    While testing on your site, I got an error in console which was being generated from jQuery inside MarketPress plugin. Please check the attached screenshot for reference.

    Though I could not regenerate any conflict between MarketPress and CustomPress, but still can you please double check you are getting the same error while MarketPress is disabled?

    I'm looking forward to hear from you and solve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

    • William
      • Syntax Hero

      Hi @Rupok

      MarketPress is not installed on this site are you referring to the membership plugin?

      I disabled the Membership 2 Pro plugin and the edit feature is now working. Please advise on how to fix this... I am getting super frustrated with this membership 2 pro plugin causing so many issues. There has been nothing but issues with this plugin (and conflicts with other wpmudev plugins) since the releases of the 2nd version!!!

      I have reactivated the plugin for now as it controls all the functionality of the website.

      Thanks,
      William

  • Ash
    • WordPress Hacker

    Hello @William

    I hope you are doing good.

    I can confirm the issue in my test site with both plugin activated. I am marking this as a bug and letting the developer know. We appreciate your patience on this.

    Thanks for reporting this, sending some points in your way.

    Have an awesome day!

    Cheers
    Ash

  • William
    • Syntax Hero

    Hi Ash, Rupok and Kasia,

    I would really appreciate a fix for this asap. I am already super behind on launching this project and it seems I'm constantly waiting for "Hot Fixes" regarding the Membership 2 Pro plugin. :slight_frown:

    Thanks,
    William

  • Ash
    • WordPress Hacker

    Hello @William

    I hope you are doing good.

    I am sorry for the delay in your thread. I have got a hot fix for you, please try the following code:

    add_action( 'admin_enqueue_scripts', 'disable_m2_validation' );
    function disable_m2_validation() {
        $screen = get_current_screen();
        if( $screen->id == 'directory_listing' ) {
            wp_dequeue_script( 'jquery-validate' );
            wp_deregister_script( 'jquery-validate' );
        }
    }

    Replace directory_listing with the custom post type you are having problem with.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • William
    • Syntax Hero

    Hi Kasia,

    Did you replaced 'directory_listing' with your custom post type?

    The custom post type is directory_listing.

    May be I am not being clear:
    I am trying add a character limit to specific custom fields that are being used by the directory plugin.

    Please see the solution that was working and has now stopped: https://premium.wpmudev.org/forums/topic/setting-a-character-limit-for-custompress-custom-fields#post-942653

    Thanks,
    William

  • Kasia Swiderska
    • Support nomad

    hello William,

    I'm really sorry it took so long to fix this. I've checked this code and it work, but unfortunately deregister scripts also from the Directory that are responsible for validation.
    So, leave the code and make additional modification in Directory plugin in files:
    /wp-content/plugins/directory/core/custompress/core/admin.php
    /wp-content/plugins/directory/core/custompress/core/content-types.php
    /wp-content/plugins/directory/core/custompress/core/core.php

    Here is screenshot with lines and what to change

    FInd string jquery-validate and change it to the jquery-validate-dir - so it will look like that

    After that and code from Ash, you should have working validation - this is from my site with Membership 2 enabled:

    let me know how it goes

    kind regards,
    Kasia

  • William
    • Syntax Hero

    Kasia,

    Do I need to move these files into my theme folder? If I update in the plugin folder it will get overridden in the next update...

    Is this a bug in the directory plugin? If so will it be fixed in the next update? If it will be fixed in the next update I suppose I would not need to move the core plugin files into my theme folder.

    Would it be better to create a function instead of updating the core plugin files? If so could you help me create this function?

    Please let me know what is the best way to go about this.

    Thanks,
    William

  • Rupok
    • Support Ninja

    Hi William

    Hope you had a wonderful day.

    Do I need to move these files into my theme folder?

    No, you need to edit the files as Ash suggested.

    If I update in the plugin folder it will get overridden in the next update

    Yes, unfortunately all core file edits will be gone when the plugin updates.

    Is this a bug in the directory plugin?

    No, this is not a bug in the directory plugin.

    Would it be better to create a function instead of updating the core plugin files? If so could you help me create this function?

    I'm afraid, this can not be created as a function instead of updating the core plugin files.

    Have a nice day. Cheers!
    Rupok

  • William
    • Syntax Hero

    Hi Rupok,

    No, you need to edit the files as Ash suggested.

    Ash never suggested editing any core files. He provided a function here. That I added to my MU-Plugin folder.

    If I don't move the core files (that Kasia suggests editing here) to my theme folder then what should I do when the next update rolls around?

    I am now thoroughly confused! :slight_frown:

    Please advise.

    William

  • Ash
    • WordPress Hacker

    Hello @William

    For now, please make the edit in core files. The issue is marked as a bug for directory plugin developer and he is working on it. Hopefully, in next version it will be released with a fix :slight_smile:

    Have an awesome day!

    Cheers
    Ash

  • William
    • Syntax Hero

    Hi Ash

    The custom fields are telling me the "maximum character limit has been reached" as soon as I click into them. I have attached screen shots. I am unable to save the page because the system thinks I have to many characters in a specific field.

    Also the "Edit" button stopped working from the "Manage My Page (page-my-listings.php)". I am no longer able to edit current listings, the page just refreshes. only Add/Create new ones. I have been dealing with this issues for a while now and I can not pin down what is causing it. The "Edit" button was working yesterday (except for in chrome) and the only changes I have made to my site where CSS changes and the core files I just updated. Can you please take a look for me?

    Kasia Swiderska The image field requirements are working again after the core updates.

    Can some one please let me know the best way to go about keeping these updates working? I did not move the core files into my theme directory.

    Thanks,
    William

  • William
    • Syntax Hero

    Hi @aknath707

    After a little further review. It looks as if I only get the error when I add a space. See attached screen shots.

    Also the "edit" only seems to be having issues in Google Chrome as of now. However I cant create a new listing to test other browsers until we get the character limit problem figured out.

    Please advise.

    William

  • Kasia Swiderska
    • Support nomad

    Hello William,

    I'm terribly sorry that you had to wait so long. Apparently regex code from Vinod was not complete, because it was checking a-z characters and 0-9 numbers. Please check this one

    ^[a-zA-Z0-9 *]{1,5}$

    there is space after 9 - I've tested it and it doesn't throw validation error when there is space in text string.

    kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.