Autor | Zpráva | ||
---|---|---|---|
H.V. Profil * |
#1 · Zasláno: 9. 7. 2014, 18:31:48
Jak mohu vypsat obsah z tohoto kódu:
<select name="user_top" id="user_top"> <option value="otevreno" <?php echo ($selected == "otevreno")? 'selected="selected"' : '' ?>>Otevřeno</option> <option value="zavreno" <?php echo ($selected == "zavreno")? 'selected="selected"' : '' ?>>Zavřeno</option> </select> příklad s výpisem if { zvoleno zavřeno = ukáže se slovo "<span>zavřeno</span>"} pokud je otevřeno, neděje se nic. |
||
Taps Profil |
#2 · Zasláno: 9. 7. 2014, 21:08:20
H.V.:
co je obsahem proměnné selected, respk. z čeho ji bereš ? |
||
H.V. Profil * |
#3 · Zasláno: 9. 7. 2014, 21:31:44
Zde je kompletní kód:
<?php function Add_user_fields( $user ) { ?> <?php //get dropdown saved value $selected = get_the_author_meta( 'user_top', $user->ID ); //there was an extra ) here that was not needed ?> <select name="user_top" id="user_top"> <option value="otevreno" <?php echo ($selected == "otevreno")? 'selected="selected"' : '' ?>>Otevřeno</option> <option value="zavreno" <?php echo ($selected == "zavreno")? 'selected="selected"' : '' ?>>Zavřeno</option> </select> <?php } add_action( 'personal_options_update', 'save_user_fields' ); add_action( 'edit_user_profile_update', 'save_user_fields' ); function save_user_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) return false; //save top update_usermeta( $user_id, 'user_top', $_POST['user_top'] ); } |
||
Časová prodleva: 10 let
|
0