WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Non Coder Wants To Add a Widget and Form (6 posts)

  1. kirkward
    Member
    Posted 1 year ago #

    Hello,

    As the title says, I am a non-coder. Actually, an old geezer non-coder.

    And, I want to code a form into a widget in the site dashboards on a multisite network.

    I want the form to have an input box for a post title, a browse and upload box for featured image and thumbnail (custom field name = thumb), and an input box for a post of content.

    I would then like the site admin to be able to click a submit button and have the data replace the existing data in a post that is in a category hidden from them by a plugin named "Restrict Categories."

    The post would be in a category named /featured/ and have a URL of http://mysite.com/featured/mypost/

    I am thinking it uses functions that are above my skill level. Things like get_page_by_path ... which are totally alien to old geezer thinking.

    I know how to add widgets to the dashboard, but not how to code this form so it works properly on each site. Can anyone give me some ideas on how to code it?

    Many thinks for any ideas and help you can give!

    Or, many thanks for even just looking at this post, since there are now 1,154,066 posts in this category, and there were 1,154,054 when I started typing.

    How the Sam Hill do you folks keep up with all this support?

  2. kjodle
    Member
    Posted 1 year ago #

    there are now 1,154,066 posts in this category, and there were 1,154,054 when I started typing.

    Thank you for noticing this. (Many people don't.) Asking good questions that eventually get answered is an art form in and of itself.

    How the Sam Hill do you folks keep up with all this support?

    Because once we learn how, we give back to the community. It's part of the philosophy behind open source software.

    and have the data replace the existing data in a post

    If you mean "replace the existing data in the same post", the only way to really do that is to execute a MySQL query. This requires knowledge of both PHP and MySQL, and the installation of a PHP Widget plugin that will allow you to enter PHP into a text widget. Impossible? No. Complicated? Yes.

    Yes, this is complicated. One of the problems people have when asking for help on a forum is that they ask questions of the form "How do I accomplish x by doing y?" or "How do I do y?" without even mentioning the desired outcome. In your case, it might be easier to come up with a better solution if we had a better idea of what you were trying to accomplish. What is the ultimate end goal?

  3. kirkward
    Member
    Posted 1 year ago #

    I think what I was wanting to use was a wp_insert_post to replace the title, images and content of a pre-written post that the user did not have edit privileges on.

    My thinking was that the form could get the post ID by URL or slug since those would not be changing, and then use that IF to insert the data from the form.

    Does that sound possible?

  4. kjodle
    Member
    Posted 1 year ago #

    a pre-written post that the user did not have edit privileges on.

    It kind of defeats the purpose of WP to have users authors edit the content of posts that they don't have edit privileges on. It's kind of like wanting someone to get into your house without giving them the key. If that's not what you're after, then I'm still confused.

    Looking at wp_insert_post(), it seems possible to do this, but it's going to take some sophisticated coding. You might want to post this request here.

  5. kirkward
    Member
    Posted 1 year ago #

    It kind of defeats the purpose of WP to have users authors edit the content of posts that they don't have edit privileges on. It's kind of like wanting someone to get into your house without giving them the key. If that's not what you're after, then I'm still confused.

    You're not confused. That is what I want.

    I have a section on the home page that is devoted to one category. I have hidden the category from the side admins using the "Restrict Categories" plugin, and I will remove the "[Edit]" link on the front end so the site admin cannot go in that way.

    This area is a section introducing the blogger (or me if they don't edit it), and I have the section laid out in a format that will be consistent from blog to blog.

    I do not want them to create new posts in this section as that will disrdisrupt the layout I have struggled for upwards of three and a half minutes to achieve.

  6. kirkward
    Member
    Posted 1 year ago #

    Got it done with a bit of Google searching, copying, pasting and seeing what happened.

    Life is good.

Topic Closed

This topic has been closed to new replies.

About this Topic