php newbie

Discussion in 'PHP' started by rober7, Dec 6, 2010.

  1. #1
    i add sime custom fields to an wordpress website and one of them is adsense (users will put their pub-xxxxxxxxxx) -> i want for the users who set this field from profile to show an adsense ad with their id but for thoose who dont to show my "pub-id"
    as much as i know i must use if function .... but i dont know how to use it ...

    i use this code to show the profile field:
    <table class="form-table">
    
    		<tr>
    			<th><label for="adsense">Adsense</label></th>
    
    			<td>
    				<input type="text" name="adsense" id="adsense" value="<?php echo esc_attr( get_the_author_meta( 'adsense', $user->ID ) ); ?>" class="regular-text" /><br />
    				<span class="description">Please enter your adsense "pub-id".</span>
    			</td>
    		</tr>
    
    	</table>
    
    PHP:
    how can i do this? :|

    (by the way ... i`m trying to make an open blog - register and start posting ... many cool options for the users ... read postin guide first --- link in my signature)
     
    rober7, Dec 6, 2010 IP
  2. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if(empty($id)){$id=$your_id;}

    now just insert your variables. ;)
     
    w47w47, Dec 6, 2010 IP
  3. rober7

    rober7 Well-Known Member

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    138
    #3
    can`t make it work ....
    this is the extra profile field :
    	<table class="form-table">
    
    		<tr>
    			<th><label for="twitter">Twitter</label></th>
    
    			<td>
    				<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
    				<span class="description">Please enter your Twitter username.</span>
    			</td>
    		</tr>
    
    	</table>
    PHP:
    and this is what i use to display
        <a href="http://twitter.com/<?php the_author_meta('twitter'); ?>"><img border="0" src="/wp-content/themes/mytheme/custom/img/twitter.png" alt="HTML tutorial" width="24" height="24" /></a>
    
    PHP:
    where should i put that code?
     
    rober7, Dec 9, 2010 IP
  4. rober7

    rober7 Well-Known Member

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    138
    #4
    is at least possible?
     
    rober7, Dec 11, 2010 IP