Forum Replies Created

Viewing 15 replies - 31 through 45 (of 261 total)
  • Thread Starter ZeroGravity

    (@zerogravity)

    Here’s the code. It has a multitude of options for constructing the random string. You can also define which characters to use in the constants.

    /**
     * Generate a random string
     *
     * Length of string to generate
     * Type of characters to use
    **/
    function createRandomString($length = 8, $type = "") {
    	$alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    	$numbers = "1234567890";
    	$symbols = "!@#$%^*()+?";
    	
    	switch(strtoupper($type))
    	{
    		case 'ALPHANUMSYM': $charString = $alphabets . strtolower($alphabets) . $numbers . $symbols; break; 
    		case 'ALPHANUM': $charString = $alphabets . strtolower($alphabets) . $numbers; break;
    		case 'UPPERALPHANUMSYM': $charString = $alphabets . $numbers . $symbols; break;
    		case 'LOWERALPHANUMSYM': $charString = strtolower($alphabets) . $numbers . $symbols; break;
    		case 'ALPHASYM': $charString = $alphabets . strtolower($alphabets) . $symbols; break;
    		case 'ALPHA': $charString = $alphabets . strtolower($alphabets); break;
    		case 'LOWERALPANUM': $charString = strtolower($alphabets) . $numbers; break;
    		case 'UPPERALPHANUM': $charString = $alphabets . $numbers; break;
    		case 'NUMSYM': $charString = $numbers . $symbols; break;
    		case 'LOWERALPHASYM': $charString = strtolower($alphabets) . $symbols; break;
    		case 'UPPERALPHASYM': $charString = $alphabets . $symbols; break;
    		case 'LOWERALPHA':$charString = strtolower($alphabets); break;
    		case 'UPPERALPHA': $charString = $alphabets; break;
    		case 'NUM': $charString = $numbers; break;
    		case 'SYM': $charString = $symbols; break;
    		default: $charString = $alphabets . strtolower($alphabets) . $numbers . $symbols;
    	}
    	 
    	srand((double)microtime() * 1000000);
    	$count = 1;
    	$randomString = "";
    	 
    	while ($count <= $length) 
    	{
    			$startChar = rand(0, strlen($charString) - 1);
    			$tempChar = substr($charString, $startChar, 1);
    			$randomString = $randomString . $tempChar;
    			$count++;       
    	}
    	
    	return $randomString;
    }
    Thread Starter ZeroGravity

    (@zerogravity)

    You can put it in your themes functions.php or create your own plugin so it’s theme independent. Did you want the code for the createRandomString function? It’s a simple one and there are many other examples across the internet you can use.

    ZeroGravity

    (@zerogravity)

    I have it running on a site with WP 5.4.4. It is working but I am concerned about the age of the plugin and for how much longer it will continue to work.

    I’m about to update the site to 5.3.3. Will see how it goes.

    Thread Starter ZeroGravity

    (@zerogravity)

    This was totally bizarre. I eventually tracked the error down to happening in FireFox on only the computer I was using. It worked in all the other browsers and all browsers on my laptop. So much time spent and it was because of the 1 browser on 1 computer.
    Aaaarrgghh!!!

    Thread Starter ZeroGravity

    (@zerogravity)

    Problem solved.

    We are using the wpmem_register_data action to modify the user_nicename, display_name and nickname when creating a user. Either $fields had been removed from the return at the end of the function or somehow miraculously it worked back in February without it.

    Thanks for all your help Chad!

    Here is the code we are using in case anyone else is looking to do the same.

    // Change names so they aren't the same as the username
    add_action( 'wpmem_register_data', 'zgwd_obscure_names', 10, 2 );
    function zgwd_obscure_names( $fields, $toggle ) {
      
    	// This is a new registration
    	if ( 'new' == $toggle ) {
    		$fields['user_nicename'] = $fields['first_name'] . ' ' . $fields['last_name'];
    		$fields['display_name'] = $fields['first_name'] . ' ' . $fields['last_name'] . ' - ' . $fields['company_name'];
    		$fields['nickname'] = $fields['first_name'] . ' - ' . $fields['company_name'];
    	}
    	
    	return $fields;
    }
    Thread Starter ZeroGravity

    (@zerogravity)

    Just realized I didn’t post my code as a solution to what I was trying to do. So ‘ere it is.

    add_filter( 'wpmem_register_form', 'zgwd1010_register_form_filter', 10, 4 );
    function zgwd1010_register_form_filter( $form, $toggle, $rows, $hidden ) {
    	$username = createRandomString( 8, 'ALPHANUM' ) . ".trh";
    
    	while ( username_exists( $username ) ) {
    		$username = createRandomString( 8, 'ALPHANUM' ) . ".trh";
    	}
    
        return str_replace( 'id="username" value=""', 'id="username" value="' . $username . '" readonly="readonly"', $form);
    }

    The createRandomString function does what it says. Creates a random string with a length of 8 characters.

    Thread Starter ZeroGravity

    (@zerogravity)

    Hi Chad (@cbutlerjr),

    Thanks for the reply.

    I turned on the debug mode to test what was might be happening with the form. I turned it off before we moved the site live.

    On the front end the form appears to work. It submits and displays the correct message but nothing happens on the back end. No user is created and none of the notification emails are sent.

    The contact forms on the website are sending without issues. So I don’t believe it would be a sending issue.

    Would I be correct in assuming the emails are generated and sent after the user is created and if there is an error creating the user then the emails may not be generated?

    I deactivated all the other plugins and tried but the result is the same.

    Thread Starter ZeroGravity

    (@zerogravity)

    How would I go about having the browser script drive the import process?

    Do you have a time frame for when this may be released? I was going to make the changes manually but the line numbers in Github don’t match those from the files I downloaded from the website. Makes me a little nervous about uploading them.

    We have v1.11.4 installed

    • This reply was modified 4 years, 4 months ago by ZeroGravity. Reason: Extra Info

    I clicked on the link and it is loading for me in both Chrome and Firefox.

    Not sure if there could be caching involved as it still seems to be loading all the testimonials. Just to make sure you were in the right place. Testimonials -> Views. Edit the view and scroll down to the “Extra” section.

    Let me know when it’s 7.1. What version of WP are you running?

    For the paging there is a setting in the views where you can set it to show a certain number of testimonials per page. If you set it to 20 then 20 testimonials will be loaded and there will be next/previous buttons on the bottom.

    Hi @my247restore,

    I have the plugin running successfully on several sites using different versions of PHP ranging from 7.1 – 7.4. Just now I installed it on a site running PHP v7.4 and it is working without any issues. The websites are all using the Genesis framework.

    I just clicked on the link you provided and the page loads for me. No sure what version you currently have PHP set to. The first time I clicked on the link it did take quite a long time to load. You may want to consider using paging so it loads more quickly.

    Thread Starter ZeroGravity

    (@zerogravity)

    Thanks @corrinarusso I will take a look.

    Thread Starter ZeroGravity

    (@zerogravity)

    Hi @pratik-jain,

    Thanks for your reply but that setting seems to remove the quantity from the checkout page as well. I only want to remove the quantity from the product page and the download button shortcode but leave it on the checkout.

    i.e. Product page and download button – no quantity.
    Checkout page – show the quantity.

    Thanks.

    Put the code below in you functions.php. I wanted to place it between the Order summary and the payment methods so I used the woocommerce_review_order_before_payment hook. If you would like it just before the payment button use woocommerce_review_order_before_submit.

    Something to consider. Clicking the “Add Donation” button reloads the checkout page, clearing the payment fields. If move the donation to after the payment options and your client has entered their credit card information it will be cleared and they will need to reenter it. They will probably find this frustrating.

    This is a great reference for all the WooCommerce hooks on the checkout page. Makes it easy to place the donation exactly where you would like it. https://businessbloomer.com/woocommerce-visual-hook-guide-checkout-page

    //* Relocate donation on checkout page
    add_action( 'woocommerce_before_checkout_form', 'wdgk_move_donation_on_checkout_page', 5 );
    function wdgk_move_donation_on_checkout_page() {
    	remove_action( 'woocommerce_before_checkout_form', 'wdgk_add_donation_on_checkout_page' );
    	add_action( 'woocommerce_review_order_before_payment', 'wdgk_add_donation_on_checkout_page' );
    }
Viewing 15 replies - 31 through 45 (of 261 total)