I'm trying to get specific links to show if the form feilds have been filled in, this is a part of wordpress using a function to get social network links to display only problem is they show even if they are empty, the form if not linked gives a link back to the page its self. <a title="Twitter" class="grey" href="<?php echo the_author_meta('twitter'); ?>">Twitter</a>, <a title="Facebook" class="grey" href="<?php echo the_author_meta('facebook'); ?>">Facebook</a>, <a title="Digg" class="grey" href="<?php echo the_author_meta('digg'); ?>">Digg</a>, <a title="Flicker" class="grey" href="<?php echo the_author_meta('flicker'); ?>">Flicker</a>, <a title="LinkedIn" class="grey" href="<?php echo the_author_meta('linkedIn'); ?>">LinkedIn</a> Code (markup): I'm not much of php coder so trying to over write the <?php echo the_author_meta('twitter'); ?> part is giving me errors and not working.
You can use [LEFT][COLOR=#000000][FONT=Consolas]if(isset($_POST['your 'name' value of the field']))[/FONT][/COLOR][/LEFT] Code (markup): That will determine if the field has been submitted.
If these are set via the admin panel: <?PHP if(the_author_meta('twitter') != "") { echo the_author_meta('twitter'); } <?> PHP: Otherwise the other solutions will work. The only issue is, this will not check to see if they are valid URL's
<?PHP if(the_author_meta('twitter')) { echo the_author_meta('twitter'); } ?> same like yours but better
Here it is. <?php add_action('show_user_profile', 'wpsplash_extraProfileFields'); add_action('edit_user_profile', 'wpsplash_extraProfileFields'); add_action('personal_options_update', 'wpsplash_saveExtraProfileFields'); add_action('edit_user_profile_update', 'wpsplash_saveExtraProfileFields'); function wpsplash_saveExtraProfileFields($userID) { if (!current_user_can('edit_user', $userID)) { return false; } update_usermeta($userID, 'twitter', $_POST['twitter']); update_usermeta($userID, 'facebook', $_POST['facebook']); update_usermeta($userID, 'linkedin', $_POST['linkedin']); update_usermeta($userID, 'digg', $_POST['digg']); update_usermeta($userID, 'flickr', $_POST['flickr']); } function wpsplash_extraProfileFields($user) { ?> Code (markup):
<?PHP if(the_author_meta('twitter') != "") { echo the_author_meta('twitter'); } else { echo "#"; } <?> PHP: at least this way, it will not link out, it will look for an anchor