Mineshrai
Forum Replies Created
-
@bcworkz,
Thanks for sharing the code. It is working perfectly but after changing the code the image is not displaying in post edit screen under project logo metabox.What to do??
Thanks.
Forum: Plugins
In reply to: [Simple User Avatar] Default avatar is not appearingUPDATE
I have updated the code as follows
if ( $user_id == 0 ) return $avatar; $custom_avatar = get_user_meta( $user_id, 'custom_avatar', true ); $image = crazicle_get_attachment_url( $custom_avatar, 'thumbnail' ); $default = "https://www.example.com/assets/images/mystery-man.png"; if( empty($image) ) { $avatar = "<img alt='{$alt}' src='{$default}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; } else { $avatar = "<img alt='{$alt}' src='{$image}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; } return $avatar;
Actually I want to display data dynamically on every project page just like we display title, content, metas etc.
In short Data of each project should be displayed on that respective project only.
I m sry as I m not able to explain u, what I mean.
Thanks @bcworkz,
I have tested this code previously but it will display data of only specific project ID. I want to display data related to every project on that particular project page dynamically.Plz help.
Forum: Developing with WordPress
In reply to: How to convert .live() to .on() in WordPressThanks @kjodle,
A slight change in your code has worked. THANKS. Following is the code for other who may stuck with the same issue.<div id="extender"></div> <p><a href="#" class="button" id="add">Add Reward</a></p> <script type="text/javascript"> jQuery(document).ready(function( $ ){ //fadeout selected item and remove $(document).on('click', '#remove', function(event) { event.preventDefault(); $(this).parent().fadeOut(300, function(){ $(this).empty(); return false; }); }); var rows = '<p><label for="amount"><b>Amount</b></label> <input type="number" style="width:100%" name="reward[]" value="" required /> <label for="est_date"><b>Est. Date</b></label> <input type="text" style="width:100%" class="datepicker" name="reward_est_date[]" value="" required /> <a href="#" class="button" id="remove">Remove</a></p>'; //add input $('#add').click(function() { $(rows).fadeIn("slow").appendTo('#extender'); i++; return false; }); $(document).on('click', '.datepicker', function() { $(this).datepicker('destroy').datepicker().focus(); }); }); </script>
Forum: Developing with WordPress
In reply to: How to convert .live() to .on() in WordPressHi @kjodle,
Thanks. I already gone through the it but was not able to convert it. Plz help me with the modified code.Hi @bcworkz,
Thanks for helping. I have added the codes accordingly but the datepicker is working weirdly. The date selected in first field get reflected in subsiquent field. Not working properly.Plz tell me where I am getting wrong. Following is the code.
function project_rewards_select_options() { $options = array ( 'Option 1' => 'Option 1', 'Option 2' => 'Option 2', 'Option 3' => 'Option 3', ); return $options; } function project_reward_callback( $post ) { wp_nonce_field( 'project_reward_nonce', 'project_reward_nonce' ); $reward_value = get_post_meta( get_the_ID(), '_project_rewards', true ); $options = project_rewards_select_options(); ?> <script type="text/javascript"> jQuery(document).ready(function( $ ){ $( '#add-row' ).on('click', function() { var row = $( '.empty-row.screen-reader-text' ).clone(true); row.removeClass( 'empty-row screen-reader-text' ); row.insertBefore( '#repeatable-fieldset-one tbody>tr:last' ); return false; }); $( '.remove-row' ).on('click', function() { $(this).parents('tr').remove(); return false; }); }); </script> <table id="repeatable-fieldset-one" width="100%"> <thead> <tr> <th width="15%">Reward Amount</th> <th width="25%">Reward Title</th> <th width="10%">Shipping</th> <th width="10%">Est. Date</th> <th width="35%">Reward Description</th> <th width="5%"></th> </tr> </thead> <tbody> <?php ( $reward_value ); foreach ( $reward_value as $field ) { ?> <tr> <td><input type="text" class="widefat" name="reward[]" value="<?php if ( isset ( $field['reward'] ) ) echo esc_attr( $field['reward'] ); ?>" pattern="[1-9]\d*" /></td> <td><input type="text" class="widefat" name="reward_title[]" value="<?php if ( isset ( $field['reward_title'] ) ) echo esc_attr( $field['reward_title'] ); ?>" /></td> <td> <select class="widefat" name="reward_shipping[]"> <?php foreach ( $options as $label => $value ) : ?> <option value="<?php echo $value; ?>"<?php selected( $field['reward_shipping'], $value ); ?>><?php echo $label; ?></option> <?php endforeach; ?> </select> </td> <script type="text/javascript"> jQuery(document) .ready(function($) { $( "#reward_est_date" ).datepicker(); } ); </script> <td><input type="text" class="widefat" id="reward_est_date" name="reward_est_date[]" value="<?php if ( isset ( $field['reward_est_date'] ) ) echo esc_attr( $field['reward_est_date'] ); ?>" /></td> <td><textarea class="widefat" name="reward_description[]"><?php if ( isset ( $field['reward_description'] ) ) echo esc_attr( $field['reward_description'] ); ?></textarea></td> <td><input type="image" class="remove-row" src="<?php bloginfo('template_directory'); ?>/assets/images/remove-icon.png" alt="Submit" width="35" height="35"></td> </tr> <?php } ?> <!-- empty hidden one for jQuery --> <tr class="empty-row screen-reader-text"> <td><input type="text" class="widefat" name="reward[]" /></td> <td><input type="text" class="widefat" name="reward_title[]" /></td> <td> <select class="widefat" name="reward_shipping[]"> <?php foreach ( $options as $label => $value ) : ?> <option value="<?php echo $value; ?>"><?php echo $label; ?></option> <?php endforeach; ?> </select> </td> <script type="text/javascript"> jQuery(document) .ready(function($) { $( "#reward_est_date" ).datepicker(); } ); </script> <td><input type="text" class="widefat" id="reward_est_date" name="reward_est_date[]" /></td> <td><textarea class="widefat" name="reward_description[]" ></textarea></td> <td><input type="image" class="remove-row" src="<?php bloginfo('template_directory'); ?>/assets/images/remove-icon.png" alt="Submit" width="35" height="35"></td> </tr> </tbody> </table> <p><a id="add-row" class="button" href="#">Add Reward</a></p> <?php } function save_project_reward( $post_id ) { // Check if our nonce is set. if ( ! isset( $_POST['project_reward_nonce'] ) ) { return; } // Verify that the nonce is valid. if ( ! wp_verify_nonce( $_POST['project_reward_nonce'], 'project_reward_nonce' ) ) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } $reward_data = array(); $options = project_rewards_select_options(); $rewards = $_POST['reward']; $reward_titles = $_POST['reward_title']; $reward_shippings = $_POST['reward_shipping']; $reward_est_dates = $_POST['reward_est_date']; $reward_descriptions = $_POST['reward_description']; $count = count( $rewards ); for ( $i = 0; $i < $count; $i++ ) { if ( $rewards[$i] != '' ) : $reward_data[$i]['reward'] = stripslashes( strip_tags( $rewards[$i] ) ); if ( in_array( $reward_shippings[$i], $options ) ) $reward_data[$i]['reward_shipping'] = stripslashes( strip_tags( $reward_shippings[$i] ) ); else $reward_data[$i]['reward_shipping'] = ''; endif; if ( $reward_titles[$i] != '' ) : $reward_data[$i]['reward_title'] = stripslashes( strip_tags( $reward_titles[$i] ) ); endif; if ( $reward_descriptions[$i] != '' ) : $reward_data[$i]['reward_description'] = stripslashes( $reward_descriptions[$i] ); endif; if ( $reward_est_dates[$i] != '' ) : $reward_data[$i]['reward_est_date'] = stripslashes( $reward_est_dates[$i] ); endif; } update_post_meta( $post_id, '_project_rewards', $reward_data ); } add_action( 'save_post', 'save_project_reward' );
Thanks dear. Its now working.
yes
It disables the field. No luck
Hi @jakept
Thanks for answering but the problem still exist. No change
Forum: Developing with WordPress
In reply to: How to display $wpdb->insert_id; value on redirected pageI am using the following code in functions.php. plz tell me is there some thing wrong.
function register_start_session() { if( !session_id() ) { session_start(); if( isset( $_POST['aname'] ) ) { $_SESSION['aname'] = $_POST['aname']; } if( isset( $_POST['aroll'] ) ) { $_SESSION['aroll'] = $_POST['aroll']; } if( isset( $_POST['insert'] ) ) { $_SESSION['insert'] = $_POST['insert']; } } } function register_end_session() { session_destroy(); } add_action( 'init', 'register_start_session', 1 ); add_action( 'wp_logout', 'register_end_session' );
Thanks
Forum: Developing with WordPress
In reply to: How to display $wpdb->insert_id; value on redirected pageThanks for ur answer. It works.
I have already started the session in functions.php file. Hence the other values where displaying on payment page.
Forum: Developing with WordPress
In reply to: Form Data not getting stored in databaseHi Thanks for ur Answer but the code is not working.
Forum: Fixing WordPress
In reply to: Problem in getting Value through POST methodThe problem is resolved
I made changes as below:
<input type="hidden" name="redirect_to" value="https://www.crazicle.com/checkout?reward=<?php echo $_REQUEST['reward']; ?>&reward_title=<?php echo urlencode($_REQUEST['reward_title']); ?>" />