add action when we have selected a user who can edit a post
-
Hello
I need to add an action when saving a post and choosing a user who can edit the post in the post permissions. When saving the post I want to get all the users who can edit this post
I tried this
add_action( 'post_updated', 'update_my_post', 1,3 ); function update_my_post( $post_id, $post_after, $post_before ) { $user = wp_get_current_user(); $roles = ( array )$user->roles; global $wpdb; //on est dans le cas de la création de post, il faut envoyer un mail au contributeur assigné au post $idPost = $post_after->ID; $sql = "SELECT DISTINCT u.ID from " . $wpdb->prefix . "ppc_exception_items pe_items LEFT JOIN " . $wpdb->prefix . "ppc_exceptions pe ON (pe_items.exception_id = pe.exception_id ) LEFT JOIN " . $wpdb->prefix . "users u ON (pe.agent_id = u.ID) WHERE pe_items.item_id = " . $idPost . " AND pe.operation = 'edit' GROUP BY u.ID"; $req = $wpdb->get_results($sql); //wp_die('<pre>Test:'.$req.'</pre>'); var_dump($req); die(); }
but $req is an empty array
I think when calling post_updated, PublishPress Permission has not modified the database yet. How to manually retrieve the list of users authorized to edit the post (selected in the permissions of the article) when saving a post?Thanks
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘add action when we have selected a user who can edit a post’ is closed to new replies.