How do i get the value from the form post that im posting within a plugin I am wanting to retrieve it i thought if i insert the form via short code that the variable on the main page would be carried over but its not maybe I need to add a shortcode that is accessable to the form inline and the insert statement above anyone any ideas.
IE On kids dashbarod page where i implment short code I already have a variable declaired called player id. This is unique to the signed in player. I need to reference that wihtin my plugin form so i can access it through the post variable or is it better using update_options my main concern their is the child could overide it in view source ?.
wp_register_style( 'ajaxgogreen-style', plugins_url( '/css/modal.css', __FILE__ ), array(), '20120208', 'all' );
wp_enqueue_style( 'ajaxgogreen-style' );
// including ajax script in the plugin Myajax.ajaxurl
wp_localize_script( 'gogreen', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php')));
function updateRedeemPoints(){
$playerId = $_POST['playerId'];
$points=$_POST['points'];
global $wpdb;
$wpdb->insert(
'4hSIc_pods_player_ranking',
array(
'points_to_redeem' =>$points,
'player_id'=>'339393',
'date_to_be_awarded' => current_time('mysql', 1),
'approved'=>'false'
));
echo 'test';
}
add_action('wp_ajax_updateRedeemPoints', 'updateRedeemPoints');
add_action('wp_ajax_nopriv_updateRedeemPoints', 'updateRedeemPoints');
function show_form(){
echo "<div id='thanks-modal' class='modal fade' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
echo "<div class='modal-dialog'>";
echo "<div class='modal-content'>";
echo "<div class='modal-header'>";
echo "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
echo "<h4 class='modal-title'>Redeem Points</h4>";
echo "</div>";
echo "<form class='form-horizontal' class='contact' name='redemmpointsForm' id='redemmpointsForm' >";
echo " <div class='form-group'>";
echo "<h3>You may only redeem the maxium points of : <?php echo $maxpoints;?></h3>";
echo "<input type='hidden' name='playerid' value='<?php echo $playerId;;?>' />";
echo "<input type='number' valuemax='<?php echo $maxpoints;?>' name='points' id='points' class='form-control' placeholder='How many points do you wish to redeem.' />";
echo "<label class='control-label col-md-4' for='Comments'>Comments?</label>";
echo "<input type='text' name='comments' />";
echo " </div>";
echo " <div class='form-group'>";
echo " <div class='col-md-6'>";
echo " <input type='button' class='btn btn-success' name='submit' id='submit' Text='Submit'>";
echo " <a href='#' class='btn' data-dismiss='modal'>Close</a>";
echo " </div>";
echo " </div>";
echo "</form>";
echo " </div>";
echo " </div>";
echo " </div>";
}
add_shortcode( 'go_greenredempoints', 'gs_redeemplugin' );
So my confusion is to what i need in this function to make player id availbe to inline form for the post. Or should i use update option and store it.
function gs_redeemplugin($atts) {
ob_start();
extract( shortcode_atts( array(
'playerId' => 'myvalue'
), $atts ) );
show_form();
return ob_get_clean();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire