dongmei2957 2013-01-01 23:17
浏览 16
已采纳

你怎么做才能在wordpress页面/帖子上有按钮,允许将它添加到一个用户profil [关闭]

I am bulding a website for a project and I want to implement a fonction but I can't seems to find a way to do it. The principe would be to have on each page one button that, when one particular user click on it, it then add it to his profil page ( that I will build) with the title of this page and an hyperlink to it. The goal here is to have some sort of activities and the user click on the ones he want to do and then it show a "to-do" list to its profile page. If you have any clue where to start, through a plugin or coding, I will really be thankful.

Have an awesome night and thanks in advance for the help

Edit : Hi guys, I am really thankful for your answers and I just want to add some details as I as indeed not so explicit in my description ( the fact that english is not my language played a role too, sorry about that) I already looked up on internet for hours and didn't find anything. Like Fergus said, I am not familliar with wordpress dev this deep. I basicly know how to add plugin, edit some easy php to make them work with my website if required. I am more business oriented but I have bases in dev in php, jquery/js, and litle bit in ajax. My goal here was more to build an Minimum viable Product in order to make an "exemple" in order to look in the futur for a technical co-funder so I don't really mind if this is not very clean code. I started reading the wordpress documentation, about the loop, the hooks, php file, template etc... So here is my technical level ;) I really appreciate your answers and will try to work with what you wrote Fergus. This is a good start and I actually have a place to start learning know. thanks a lot

  • 写回答

1条回答 默认 最新

  • doubi9999 2013-01-02 00:09
    关注

    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:

    1. You need to... display a button on each page
    2. You need to... store data about a users selected pages
    3. You need to... retrieve pages associated with a specific user
    4. 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:

    1. How a plugin displays data in a Wordpress Page.
    2. 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决