Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more information on creating custom events #31

Open
joshuarichard opened this issue Aug 17, 2015 · 4 comments
Open

Provide more information on creating custom events #31

joshuarichard opened this issue Aug 17, 2015 · 4 comments

Comments

@joshuarichard
Copy link

I know this repo has been a little stale lately, but I'm looking for any guidance on adding a new event. I read the docs but below was all I found and it was mind-numbingly unhelpful:

// It's possible to add more events using slack_get_events filter. 
// Here's an example to add new event when a user is logged in:
add_filter( 'slack_get_events', function( $events ) {
    $events['user_login'] = array(
        'action'      => 'wp_login',
        'description' => __( 'When user logged in', 'slack' ),
        'message'     => function( $user_login ) {
            return sprintf( '%s is logged in', $user_login );
        }
    );

    return $events;
} );

I'm trying to add a page creation/deletion/update event. All I'm trying to get answered is where would add_filter() even go, the only instance of it is found in /includes/post-type.php and the code in there doesn't bear any resemblance to the example code above. I can troll the slack API after that.

@michael-cannon
Copy link

Short

See https://github.com/gedex/wp-slack-edd/blob/master/slack-edd.php#L35 for example usage.


Long

I'm not positive, but the key here lies in the $events arrary. I suspect that user_login is whatever name you give to the WordPress API Action wp_login that's being fired. So if you look through the Plugin API/Action Reference you can edit the action setting in above with an action name.

Further did you see how filter slack_get_events is called by

to fire off for the various events? That might more.

Don't forget to Add New the Slack integration from within WP Admin once you've added the code.

@gedex gedex added this to the Future Release milestone Oct 21, 2015
@christ0ph3r
Copy link
Contributor

@gedex do you want user login trigger added in main plugin for future release? If so, I can work on this.

@mayeenulislam
Copy link

mayeenulislam commented Jul 26, 2016

@christ0ph3r IMHO, the features that can be implemented in core for easy integration could be all the features like: https://wordpress.org/plugins/user-activity-log/

If the user want something, will check it. But if you want the plugin more neat and light, the existing is simply awesome.

Just make an awesome documentation with all sorts of information.

@roberthuttinger
Copy link

trying to use the action hooh edit_post which only returns an ID. Still doesnt show a notification.

add_filter( 'slack_get_events', function( $events ) { $events['post_updated_rc'] = array( 'action' => 'edit_post', 'description' => __( 'When a post is updated', 'slack' ), 'message' => function( $post_updated_rc ) { return sprintf( '%s updated', $post_updated_rc ); } ); return $events; } );

Im making the assumption here that $post_updated_rc is the returned values from the original action call.

Anyone have luck getting notifications on updates working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants