Member Avatar for vijiraghs

Hello,

I have setup a wordpress locally in WAMP.

Every user is given points for writing. I want to write a piece of code that will add two points to the user's existing points every time he writes a blog.

Can this be done usng php? Also, where should I deploy this code so that it will run everytime any user of the website writes a blog?

Any help is appreciated.

Thanks in advance.

Yes, on logging in each user will have a session, also opening the data relevant to them from an SQL query... Look at where the sumbit blog button code is and add the 2point's global variable to the user's total points variable which can then be stored in the user's records of the backend database using an INSERT SQL query.

PHP Sessions
http://www.w3schools.com/php/php_sessions.asp

PHP/MYSQL
http://www.w3schools.com/php/php_mysql_insert.asp

the simplest way is to pull the users current points from say TABLE users

so a row in USERS will be mypoints

return mypoints on the submission

and do the following

$oldpoints = $row;
$newpoints = 2;

$totalpoints = $oldpoints + $newpoints;

this will add 2 points on top of the users oldpoints / currentpoints

this can also be used when you want to subtract points for a action

Member Avatar for vijiraghs

Thanks a lot...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.