Last active
October 24, 2018 09:41
-
-
Save moskalukigor/1ab0e894247e64e4d5ec1c8dada28e1d to your computer and use it in GitHub Desktop.
Show only user loaded images in ACF Gallery in frontend using acf_form | And grant user permission to upload files and change published page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$role = new WP_User( $userID ); | |
$role->add_cap('upload_files', true); | |
$role->add_cap('edit_published_pages', true); | |
add_filter( 'posts_where', 'devplus_attachments_wpquery_where' ); | |
function devplus_attachments_wpquery_where( $where ){ | |
global $current_user; | |
if( is_user_logged_in() ){ | |
// we spreken over een ingelogde user | |
if( isset( $_POST['action'] ) ){ | |
// library query | |
if( $_POST['action'] == 'query-attachments' ){ | |
$where .= ' AND post_author='.$current_user->data->ID; | |
} | |
} | |
} | |
return $where; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment