GithubHelp home page GithubHelp logo

Comments (4)

timkelty avatar timkelty commented on August 29, 2024 2

It doesn't look like it it listening for an author/authorId in the request either, so you'd have to do something like this:

        Event::on(
            GuestEntriesSaveController::class,
            GuestEntriesSaveController::EVENT_BEFORE_SAVE_ENTRY,
            function (GuestEntriesSaveEvent $event) {
                $entry = $event->entry;
                $currentUser = Craft::$app->getUser()->getIdentity();

                if ($currentUser) {
                    $entry->authorId = $currentUser->id;
                }
            }
        );

from guest-entries.

timkelty avatar timkelty commented on August 29, 2024 1

@brandonkelly yep - I think the use-case here is having a form that can do either - submit as a user or anonymous.

So, you could either do as I did above, or toggle the action to entries/save-entry in your template based on currentUser.

from guest-entries.

stursby avatar stursby commented on August 29, 2024

@timkelty Thank you for this! I was also trying to assign the currentUser to the author (with no luck from the front-end <form>). This did the trick!

from guest-entries.

brandonkelly avatar brandonkelly commented on August 29, 2024

Yeah the plugin isn’t concerned with the logged in user – the whole point is to provide a save-entry endpoint for guest users; if you have an entry saving form for logged-in users, ideally that is going through the entries/save-entry controller, as demonstrated by the Entry Form example in the docs.

from guest-entries.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.