Skip to:
Content
Pages
Categories
Search
Top
Bottom

Needing to Find Out Functions Associated With Certain Actions

  • Is there a reference that gives me the functions associated with certain actions? or do I have to search through all of the buddypress files? I’m looking for the function associated with
    `do_action( ‘bp_after_signup_profile_fields’ )` as well as a several other registration actions.

Viewing 12 replies - 1 through 12 (of 12 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    Use grep. That’s what I do. From the UNIX or Mac Terminal command line, cd to your buddypress installation directory. Then:
    `grep -nR ‘bp_after_signup_profile_fields’ ./`

    That’ll tell you all the locations of all the instances of that text.

    In the case of this particular do_action, I am pretty sure it is just there for the use of other plugins. I don’t believe it does anything in BuddyPress itself.

    “I don’t believe it does anything in BuddyPress itself.”

    I’m sorry, I don’t understand what you mean with this line. From my understanding, every action has a function associated with it somewhere in the BuddyPress files. The line `do_action(‘bp_after_signup_profile_fields’)` (in the register.php file), seems like it does something like in the registration process…maybe some sort of an evaluation to make sure the user is ready for the next step…whatever that something is I’m trying to figure it out…

    Now, I’m not familiar with “grep” and never used it. You say that it’ll tell me all of the instances of that text. Does that give me the function(s) associated with that action?


    Boone Gorges
    Keymaster

    @boonebgorges

    Instances of do_action() don’t, in themselves, do anything. They are signposts (‘hooks’, in WordPress terminology) that allow other plugins to add functionality. It is thanks to such idle hooks in WordPress that BuddyPress is able to function. See https://codex.wordpress.org/Plugin_API for more info about how the system works.

    Grep will tell you the locations of all references to the text you provide. Generally, that will give you enough information to open up the file(s) given in the grep results and look at the specified line. I just ran the command I gave you above, and I got the following result:
    `./bp-themes/bp-default/registration/register.php:162: `
    In other words, as I suggested, this particular text is only mentioned in one place in BP – the moment where it is defined. The hook is not called by any function in BuddyPress.

    Okay…please forgive my misunderstanding…but then what role does “ play in register.php if it isn’t called by any function in BuddyPress? why is it even there?


    pcwriter
    Participant

    @pcwriter

    As Boone hinted in his earlier post, these hooks can be used by plugins to add functionality to Buddypress.

    For example, the Buddypress Humanity plugin uses the do_action( ‘bp_before_registration_submit_buttons’) hook, also found in register.php, to add an additional field that must contain text matching a site-admin-defined value from the database to validate the registration process, and allow the signer-upper to continue to the next step.

    ooohhhh…got it…so it’s there in register.php ‘just in case’ I want to do something at that point in the registration process. I got it…


    stwc
    Participant

    @stwc

    Good lord. After all this time and having read so many pages of doco and stuff, I think this thread finally made me understand what hooks actually are. Thanks, Boone!


    Boone Gorges
    Keymaster

    @boonebgorges

    Hooray for understanding!! :)


    modemlooper
    Moderator

    @modemlooper

    @stwc are you serious? You’ve been around here for awhile. Hooking into action is one of the easiest ways to add stuff to a theme. Wanna add ad block above activity stream? Just drop a function in BP-custom and attach to do action above stream. Almost evrything in BP has an do action before and after.


    stwc
    Participant

    @stwc

    @modemlooper I know, I know. *hangs head in shame*

    I mean I knew how to futz around with them, but I never really *got* it before.


    Boris
    Participant

    @travel-junkie

    @stwc
    No need for hanging your head anywhere :) I still remember being really confused by all that filter-action-akadabra-hook-mumbo-jumbo. I’d been using it for a while knowing that it did the things I wanted without really understanding how it did it. Once you do understand it though, it opens up a lot of possibilities, especially when it comes to making your own themes/plugins pluggable.

    Actions basically add things like markup and/or server-side validation exactly at the point where the do_action calls appear, while filters let you modify/change existing data, like variables, objects or arrays whenever there is a apply_filters call…


    dains
    Participant

    @dains

    Although your problem seems to be solved, I wanted to add this in – https://codex.buddypress.org/developer-docs/ . On the right is a reference for some add_action functions. However, there’s a ton of stuff in there that has no documentation :(

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Needing to Find Out Functions Associated With Certain Actions’ is closed to new replies.
Skip to toolbar