Full disclosure: I wouldn’t generally answer this type of question as it’s incredibly broad and seems to possess very little information; where more is required to truly answer it. However, it got me pondering something I’ve been wondering about and I’ve answered it anyway.
In future try and put some more information in your questions, tell us what you’ve researched and what you’ve tried and so on. Nobody wants to spend time writing out an answer to someone who wont even do a a quick Google search themselves!
Breaking it down
You need to provide some clear requirements – if you have any that is. If you don’t have any, then you need to think of some. For example, from breaking down your post the obvious requirements are:
- You need to… display a button on each page
- You need to… store data about a users selected pages
- You need to… retrieve pages associated with a specific user
- You need to… display those pages on the users profile
Displaying a button
Have a button in the template; with an associated jQuery event handler for it? This isn’t an elegant solution as it mixes logic with the view – making future maintainability and design changes a pain.
In which case, I’d begin looking at WordPress Plugin Development – with the first requirement of the plugin to simply display a button – as well as output the required jQuery event handlers.
For implementing this you could look at existing plugins; easy things like source code viewers would show you how to inject scripts and mark-up into a page. Hell, any plugin should be able to show you how to do this!
Storing user data
This will have to be done in the wordpress database. So once again you could look at other plugins that conduct database operations and build a solution from there; or you could check out the wordpress plugin ‘Function Reference’ and set about ‘hacking something together’; it’s probably best to see how others achieve it first though.
This part of your plugin literally just needs to take the page and the user, that’s all that really needs to be done.
Retrieving pages associated with a user
Ditto the above. You need to be able to take a username or user ID and return the specific pages that this user has clicked on. This could almost be described as just the above in reverse; similarly – bare this in mind when implementing it!
Displaying the data to a user
Think back to the first requirement: displaying a button. You need to be able to output specific data to the screen. The lessons learnt from here will come in very useful again.
So… With this in mind
You now have to consider what tools you’re working with and how confident you really are. I get the impression you haven’t worked with WordPress before at this level – but have you worked with PHP? jQuery/Javascript? Do you have an understanding of MySQL and the way WordPress stores data in databases?
Then condense what I’ve said above and find out:
- How a plugin displays data in a WordPress Page.
- How a plugin can interact with the database.
In the Plugin API you may want to examine Actions as these appear to provide a wrapper for the core functionality of your plugin. Similarly, examine the available Hooks and determine when which part of your plugin is required to run.
As for database interaction? The WordPress Documentation has pretty extensive information on this too.
There are plenty of documents online about plugin development; and this one details how to modify HTML output using filters. A quick google will probably provide you with 95% of what you need to know, the other 5% could probably be gained with a pen and pencil and a 10minute brainstorm.
In conclusion; break down your requirements in to easier chunks and do some research to see how these bits can be achieved. Then plan on how to integrate it all together as one package. It’s too big a question to provide a whole answer to.
I will confess to never having developed a plugin myself, but I’ll link you to the seemingly brilliant documentation for it. Similarly, if you haven’t worked with jQuery before – here’s the $.ajax() method documentation.
4
solved How would you do in order to have buttons on wordpress page/post that permit to add it to one user profil [closed]