I’m using Dokan on a WooCommerce marketplace. I’ve already made the Shop URL field optional for vendor registration using filters, and vendors can now successfully register without filling that field. However, the Shop URL field still shows a red as

WPTurbo » Snippets » I’m using Dokan on a WooCommerce marketplace. I’ve already made the Shop URL field optional for vendor registration using filters, and vendors can now successfully register without filling that field. However, the Shop URL field still shows a red as
0

Created with:

Visibility: 

public

Creator: TO

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
					<?php

// Add a filter to change the registration text on the my-account page
add_filter( 'gettext', 'furnimax_replace_registration_text', 20, 3 );

/**
 * Replace the registration text on the my-account page.
 *
 * This function checks the translated text for the WooCommerce domain
 * and replaces a specific string related to the registration process.
 * It targets the text that instructs users to fill in registration fields
 * and modifies it to refer to the fields on the left side of the page.
 *
 * @param string $translated_text The translated text to be checked against the original.
 * @param string $text The original text from the source that is being translated.
 * @param string $domain The text domain used for translation, which helps to identify
 *                       the context of the string being translated.
 * 
 * @return string Modified text if a match is found; otherwise, the original translated text.
 */
function furnimax_replace_registration_text( $translated_text, $text, $domain ) {
    // Check if the current text domain is WooCommerce
    if ( 'woocommerce' === $domain ) {
        // Original text to look for in the translation
        $original = "Just fill in the fields below, and we’ll get a new account set up for you in no time.";
        
        // Replacement text that will be used instead of the original
        $replacement = "Just fill in the fields to the left, and we’ll get a new account set up for you in no time.";

        // Try to replace the text and log any errors
        try {
            // If the translated text matches the original text, replace it with the new text
            if ( $translated_text === $original ) {
                return $replacement; // Return the new text
            }
        } catch ( Exception $e ) {
            // Log the error message
            error_log( 'Error in furnimax_replace_registration_text: ' . $e->getMessage() );
        }
    }

    // If no match is found, return the original translated text
    return $translated_text;
}
				

Replacing text description in the My Account area

Register an account to save your snippets or go Pro to get more features.