Support

Account

Home Forums Front-end Issues relationship field in front-end post not loading fields

Solved

relationship field in front-end post not loading fields

  • Hello everybody…

    Thank you for the beautiful plugin and sorry for my bad english …

    I’m trying to create a new post with custom ACF fields from the front end …
    Everything works perfect, but if i log in not as administrator the relationship field doesn’t load the “related post” … just as administrator the fields are correcttly loaded and displayed… i’m using wordpress 3.6 and buddypress 1.8 and ACF 4.2.2 .

    Do you have some suggestion to give me ?

    thank you very much and good job …

  • Hi @carlitos

    Can you elaborate a bit more on this issue. Do you mean, on a front end form (created with acf_form() ) the relationship field is not loading in any items in the left hand column?

    Have you checked your console log for any JS errors?

    Thanks
    E

  • 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 !

  • Hi @carlitos

    Thanks for the detail. If you comment out the add_filter, does the relationship field work as expected.

    It makes sense that this filter is causing the relationship AJAX call to fail.

    Let me know

    Thanks
    E

  • 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 !

  • 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

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘relationship field in front-end post not loading fields’ is closed to new replies.