creating different edit screens for different roles

Solved it for different edit pages for different roles. In my method resposible for rendering the field I have: if ( count( array_intersect( $allowed_editors, $user->roles ) ) < 1 ) $readonly = ‘readonly’; Which I later use to either set the input field as readonly or add/remove classes before rendering it. Still working for the … Read more

Different email notifications (about pending posts) to different users

add_action(‘future_to_pending’, ‘send_emails_on_new_event’); add_action(‘new_to_pending’, ‘send_emails_on_new_event’); add_action(‘draft_to_pending’, ‘send_emails_on_new_event’); add_action(‘auto-draft_to_pending’, ‘send_emails_on_new_event’); /** * Send emails on event publication * * @param WP_Post $post */ function send_emails_on_new_event($post) { $emails = “[email protected], [email protected]”; //If you want to send to site administrator, use $emails = get_option(‘admin_email’); $title = wp_strip_all_tags(get_the_title($post->ID)); $url = get_permalink($post->ID); $message = “Link to post: \n{$url}”; wp_mail($emails, “New post … Read more

Disallow “contributors” to edit their own posts once they’ve been set to “Pending Review”

You can do this by checking if the post author is a contributor and post status is pending before the post is saved. Before the post is saved: add_filter( ‘wp_insert_post_data’, ‘disallow_edit_pending_3748’, 99, 2 ); function disallow_edit_pending_3748( $post_data, $post_array ){ if( ‘pending’ == $post_data[‘post_status’] && current_user_can( ‘contributor’ ) ){ // there’s no other way to do … Read more

Admin Post List Only Show One Category

I found a hacky solution involving redirecting the user: if ((basename($_SERVER[‘SCRIPT_NAME’]) == ‘edit.php’)) { // your code here $author = wp_get_current_user(); if(isset($author->roles[0])){ $current_role = $author->roles[0]; }else{ $current_role=”no_role”; } if($current_role == ‘ai1ec_event_assistant’ && ($_GET[‘post_type’]==”&&$_GET[‘category_name’]==”)){ header(“Location:/wp-admin/edit.php?category_name=events-list”); } }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)