Wordpress - Adding custom fields from front end

Discussion in 'PHP' started by cloudex99, Dec 10, 2011.

  1. #1
    I'm trying to allow users to add custom fields from the front end through a form. I know i'm on the right track but it just isnt working. If someone could help me get this working I'd be grateful. Here's my code:

    
          <form name="input" action="" method="get">
           Mirror link: <input type="text" name="mirror">
           <input type="submit" value="Submit" />
           </form>
    
    <?php
    
    
    
    $link = $_GET['mirror'];
    
    
    
          if (substr($link, 0, 29) == "http://www.novamov.com/video/"){
    
                  $novamov = $link;
                  
                      add_post_meta($post_id, 'novamov', $novamov);
    
    
          }
    
          if (substr($link, 0, 26) == "http://videozer.com/video/") {
             
                  $videozer = $link;
    
                      add_post_meta($post_id, 'videozer', $videozer);
    
          }
    
          else {
           
                    echo "Sorry we do not accept this host.";
    
           }
    
    ?>
    PHP:

     
    cloudex99, Dec 10, 2011 IP
  2. ekaddu

    ekaddu Active Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #2
    is it echo-ing sorry we do not... or what
     
    ekaddu, Dec 10, 2011 IP
  3. cloudex99

    cloudex99 Well-Known Member

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    126
    #3
    A user enters a video url, if it is videozer or novamov then it accepts it and creates a custom field storing those links. If it is not the specified video hosts it echo's "Sorry we do not accept this host.". Well that is what is supposed to do any ways.

    Is there anyone that can help me with this? Please...
     
    cloudex99, Dec 10, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Maybe - what is it doing?
     
    Rukbat, Dec 10, 2011 IP
  5. cloudex99

    cloudex99 Well-Known Member

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    126
    #5
    ....my previous post explains exactly what it is doing. However, I shall give an example: http://bestanimes.tv/working-2-episode-11/
    When the link is submitted it is not saved as a custom field. That is my problem. I am not trying to output the custom field yet, just want to store it.
     
    cloudex99, Dec 10, 2011 IP
  6. Karl-

    Karl- Greenhorn

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #6
    Looks fine to me, if nothing is being added to the database you need to investigate the function add_post_meta(); and see if it's the correct one you should be using.
     
    Karl-, Dec 10, 2011 IP
  7. ekaddu

    ekaddu Active Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #7
    the only problem i can see is when a novamov.com link is added, the first if condition satisfies. then it checks whether the second if is true or not which isn't, obviously. and hence the else part executes and "sorry we do not accept" is printed. if this is the problem then changing second if to else if would be the solution.
     
    ekaddu, Dec 10, 2011 IP
  8. cloudex99

    cloudex99 Well-Known Member

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    126
    #8
    Tried else if. That is not the problem here. The problem is that the custom field isn't being added. I'll pay 10$ to who ever can get this working.
     
    Last edited: Dec 11, 2011
    cloudex99, Dec 11, 2011 IP
  9. animedbsellersz

    animedbsellersz Well-Known Member

    Messages:
    276
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    123
    #9
    hi pm me if you still need help...this is so simple...i dont want to post the solution here..all leechers will copy it :D
     
    animedbsellersz, Dec 20, 2011 IP
  10. cloudex99

    cloudex99 Well-Known Member

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    126
    #10
    I already got it working, but thanks anyways :).
     
    cloudex99, Dec 20, 2011 IP