Skip to:
Content
Pages
Categories
Search
Top
Bottom

Help with A Hook?

  • Avatar of twodeuces
    twodeuces
    Participant

    @twodeuces

    I am re-working the Auto Join Groups Plugin to allow new users to auto join selected groups upon signup for the site. I’m a little rusty on my php, but have managed to get most of it working. BUT I need a little help….

    I need to know what Action Hook would be best to attach the “auto Join” function to after the user has registered. Let me be a little more specific. I really need some guidance on how to determine what the hooks are in the php code. Also how would I pass the new user’s ID back to the plugin to add him/her to the selected groups.

    Any help will be greatly appreciated and will help bring this plugin back to life.

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    Make sure you have read this first: http://codex.wordpress.org/Plugin_API

    Here you can find a listing of most (all?) of the current WordPress hooks: http://codex.wordpress.org/Plugin_API/Action_Reference

    Here you can find a listing of BuddyPress hooks, although this is out of date:

    http://codex.buddypress.org/developer-docs/action-reference/

    As far as your particular project, you probably can find the proper hook to tie into by searching the register.php file in the BP default theme. There are many hooks you can use.

    Also, if you want to learn more about the current BuddyPress hooks, I would recommend searching for all “do_action” and “apply_filter” calls within BuddyPress.

    Avatar of twodeuces
    twodeuces
    Participant

    @twodeuces

    I had read those pages before, and I was struggling with the out of date buddypress hooks. I wanted to confirm that the “do_action” call is the hook ‘enabler’ sort of speak. Would I be correct if I ventured the variable in the do_action function call would be the actual hook name that I could hook into?

    For example:

    do_action( ‘bp_core_something’)

    The ‘bp_core_something’ is the hook I could add_action to?

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    Yes.

    function do_something_cool () {

    // Code to do something cool

    }
    add_action( 'bp_core_something', 'do_something_cool' );

    You could even add your own custom hook so that others could then modify the outcome of your do_something_cool function. So:

    function do_something_cool () {

    do_action( 'before_something_cool' );

    // Code to do something cool

    do_action( 'after_something_cool' );

    }
    add_action( 'bp_core_something', 'do_something_cool' );

    Avatar of twodeuces
    twodeuces
    Participant

    @twodeuces

    Thanks for the help Jeff!

    I was able to get it all sorted out! Yeah! Now when users register they will automatically be added to the selected groups!

    I am currently using WPMU, so I am using a WPMU Hook. Is there an easy way to register actions using either WP or WPMU Hooks so there wouldn’t need a second version of the plugin for single user wordpress.

    The hook I am currently using is wpmu_new_user and I believe the single user equivalent is user_register. Is there a global value available to do something like this…

    if ( $wpmu ) {

    add_action ('wpmu_new_user', 'auto_join_new_user');

    } else {

    add_action('user_register', 'auto_join_new_user');

    }

    Avatar of sirspacey
    sirspacey
    Member

    @sirspacey

    @twodeuces I’m trying to make it so when a user clicks “Join group” they are taking to the group’s page, instead of left on the directory. could you provide me with some clues on how to do that?

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

You must be logged in to reply to this topic.