vendredi 20 mars 2015

PHP If Checkbox Checked, Then (WordPress)

Intro


I have some custom fields in my WordPress profile area. Here's an example of a checkbox in my code:



<input type="checkbox" name="A" id="A" value="yes" <?php if (esc_attr( get_the_author_meta( "A", $user->ID )) == "yes") echo "checked"; ?> /><label for="my_field "><?php _e("Order Button"); ?></label><br />


This field is A, and I'm saving it in the same file with:



update_usermeta( $user_id, 'A', $_POST['A'] );


This is working, and when the user clicks it on or off, it saves.


The Problem


However, I am having a big issue posting the results if the checkbox was checked.


In another file I have this:



if(isset($_POST['A'])) {
echo 'asd';
} else { }


I have tried a lot of variations, but I can not figure out how to get the If statement to check whether the user checked the box or not, it only echos the else.


TL;DR:


I can't figure out how to check if the usermeta is checked or not, and how to output that into another element of the website.


http://ift.tt/1CDwdBP Link to User Profile Code


http://ift.tt/1HbfWTK Link to Header area where I'm trying to call the checkbox.





Aucun commentaire:

Enregistrer un commentaire