Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can I affect while-loop execution via a do_action function?


  • dwdutch
    Participant

    @dwdutch

    I want certain data (e.g. annual-membership-status) to be associated with an individual member but not allow the individual member to change the field’s content – such changes can only be done by the site-administrator.

    My strategy is to put all such fields in an xprofile group called “Admin-only” then create a function to hook in edit.php via do_action( ‘bp_before_profile_field_content’ ) that would cause the edit.php loop to NOT display the Admin-only group if the user wants to edit their profile data. in this fashion, the information would be visible ot the user just not administrable.

    Whereas, this seems to be the perfect place to add my hook while the core code is looping to generate the xprofile display groups, I can’t figure out how to affect the actual edit.php loop processing from my do_action replacement function. Ideally, I’d have something like the following in my functions.php file:

    <?php
    function skip_group () {
    if ( bp_get_the_profile_group_name() == “Admin-only” && !is_site_admin() ) {
    // my attempt to cause the primary while loop in edit.php to advance to
    // the next iteration without displaying fields for the current group.
    continue;
    }
    }
    add_action( ‘bp_before_profile_field_content’, ‘skip_group’ );
    ?>


    p.s. yes, I understand WHY the above code won’t work because of the inability of the “continue” to impact beyond the scope of the enclosing function — i just can’t figure out an alternative approach.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can I affect while-loop execution via a do_action function?’ is closed to new replies.
Skip to toolbar