Thank you @elliot ,
i use this code
add_action('admin_init', 'wpse28702_restrictAdminAccess', 1);
function wpse28702_restrictAdminAccess() {
$isAjax = (defined('DOING_AJAX') && true === DOING_AJAX) ? true : false;
if(!$isAjax) {
if(!current_user_can('administrator')) {
wp_die(__('You are not allowed to access this part of the site'));
}
}
}
and everything it’s ok …
thank you very much
Hi @elliot,
Thanks for support, i found where was the problem with my configuration …
// block buddypress users to see wp-admin when logged-in
function block_wp_admin_init() {
if (strpos(strtolower($_SERVER['REQUEST_URI']),'/wp-admin/') !== false) {
if ( !is_site_admin() ) {
wp_redirect( get_option('siteurl'), 302 );
}
}
}
add_action('init','block_wp_admin_init',0);
I’m so stupid … this code obviously block wp-admin/admin-ajax.php to load …
How can i work around this ? i must push away my users from wp-admin …
Do you have some idea ? …
Thank you again for the help … it’s always usefull to talk with another developer … should i close the topic as solved ?
have a good day elliot !
Hi Elliot, thanks for replying …
Yes , i followed your tutorial to post with the front end form (acf_form()) but the relationship field is not loading in any items in the left hand column when i’m logged in not as administrator ( that’s because all my site is visible only for logged in user … maybe it can be related with my problem…). The others field work well … the post is created and saved ..
the chrome console doesn’t show me any js error but if i try to log the xhr request the console show me nothing like no XHR has been sent …
sorry for my bad english and thanks for help…
this is the code in functions.php for block not logged in user i don’t know if can be useful… i don’t know where to put my hands … i’m a newbie developer …
// block site for non users
function bp_guest_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_members_component() || bp_is_profile_component() || bp_is_forums_component() || bp_is_friends_component() || bp_is_settings_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {
// enter the slug or component conditional here
if(!is_user_logged_in()) { // not logged in user
wp_redirect( get_option('siteurl') . '/welcome' );
} // user will be redirect to any link to want
}
}
add_filter('get_header','bp_guest_redirect',1);
thanks for your work Elliot and have a good day !
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.