This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Shahiem
Shahiem

I'm working on a Social publisher and I want to extend the onCreate method. When you create your blog post, I want to send a message after that.

Someting like this:

Event::listen('rainlab.blog.onCreate', function() {

        $twitter =  new Twitter();

        // Send Tweet

    });

Already try that, but it doesn't work. Is there an other whay to do this? I hope you guys can give my any advise. Thank you

Last updated

felix.gerdes5938
felix.gerdes5938

What happen excactly? Error message or is the event not fired?

Flynsarmy
Flynsarmy

Shahiem you probably want

Post::creating(function() {
    $twitter = new Twitter();
});

I don't feel this is particularly good practice though. Often I'll want to revise my post many times after creating it before I want it to go public on social media. A 'Publish this on Twitter' button on the blog post admin page would be a better idea IMO.

Shahiem
Shahiem

Thank you, I was looking for that :), I think you suggestion might be beter than my idea. So I'll try that out.

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.