• Hello, im using this amazing plugin, but i need to use it so the members of the platform can send to the page admin some transactions, and in order to do that i took the TRANSFER TO USER WALLET WIDGET and i need to modify it, so that when it pops up it already has selected the admin user for the transfer and the clients don’t get confused

    	<td colspan="3">
    					<label class="user"><?php echo apply_filters( 'wallets_ui_text_recipientuser', esc_html__( 'Recipient user', 'wallets-front' ) ); ?>: 
    					<input id="userInput" list="<?php echo esc_attr( $uid = uniqid( 'wallets-move-' ) ); ?>" type="text"  required="required" placeholder="<?php echo apply_filters( 'wallets_ui_text_enterusernameoremail', esc_html__( 'dmalab.co', 'wallets-front' ) ); ?>"
    					data-bind="value: moveUser, valueUpdate: ['afterkeydown', 'input']" onclick="myFunction"  /></label>
    					<datalist id="<?php echo esc_attr( $uid ); ?>">
    						<?php foreach ( Dashed_Slug_Wallets::get_move_recipient_suggestions() as $user_name ): ?>
    						<option value="<?php echo esc_attr( $user_name ); ?>">
    						<?php endforeach; ?>
    					</datalist>
    				</td>
    

    That is the part of the form that i need to modify, simply put in the input ‘admin’ and make it work, but of course that data-binding doesn’t let me just add value=”” or something and i’m stuck because i checked in wallets-ko.js and tried to adjust it there and it simply doesn’t work, i really need help ?? Sorry

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author dashed-slug.net

    (@dashedslug)

    Hello,

    First of all, to see why you should’t be editing the plugin’s code, please read the FAQ under “I want to do changes to the plugin’s code.”

    I will give first a long explanation on how to approach this, and then also a complete solution.

    You cannot set the value attribute directly, because the form’s input fields are bound to knockout.js “observables”. “Observables” are simply variables that are part of the viewmodel.

    This particular observable is moveUser and is found here: https://github.com/dashed-slug/wallets/blob/4.4.8/assets/scripts/wallets-ko.js#L353

    You can set the observable like so: wp.wallets.viewModels.wallets.moveUser('admin');.

    To do this, you would first need to wait for the wallet’s front-end to load. When the front-end loads, it fires a wallets_ready bubbling event that you can catch at the root of the DOM, like so:

    jQuery( 'html' ).on( 'wallets_ready', function( event, coins, nonces ) {
    	wp.wallets.viewModels.wallets.moveUser('admin');
    }

    The trick is to add this in your child theme, so that even if all the plugins and your theme get updated, your code doesn’t get wiped out. One quick way to do this is to add the following to your child theme’s functions.php file:

    function set_move_recipient() {
    	?>
    	<script>
    		jQuery( function() {
    			jQuery( 'html' ).on( 'wallets_ready', function( event, coins, nonces ) {
    				wp.wallets.viewModels.wallets.moveUser('admin');
    			} );
    		} );
    	</script>
    	<?php
    }
    add_action( 'wp_head', 'set_move_recipient' );

    Hopefully your theme knows about the wp_head action, as some low-quality themes don’t use it. If that’s the case, add the JavaScript code into your site some other way.

    Hope this helps. Let me know if you need any help implementing this into your theme.

    with regards,
    Alex

Viewing 1 replies (of 1 total)
  • The topic ‘Default Transaction’ is closed to new replies.