Support » Fixing WordPress » Insert value in table when new post is created.

  • Good day everyone! Hope you’re having a great weekend. 🙂 I’m having fun as usual with WordPress.

    I’m working on a personal plugin for voting posts up or down. I’m disallowing visitors to vote more than once by storing their IP addresses. I created 2 new tables in my WordPress database.

    The first one stores IPs

    VOTE_IPS
    id (primary auto-increment)
    post_id (id of voted post)
    vote_ip (the voters IP address)

    And the second table shows how many votes each post has.

    POST_VOTES
    id (primary auto-increment)
    post_id
    up
    down

    Instead of making the POST_VOTES table I could have just added “up”, and “down” rows in the default wp Post table but I want to keep the votes separate.

    When I publish a new article in wp, is there a way to add it’s post id into the post_votes table? I’m trying to figure out if I can add a function to the plugin file for this rather than editing any core files. This is way beyond me, I would really appreciate some help!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert value in table when new post is created.’ is closed to new replies.