BuddyDev

Search

[Resolved] Creating a BP custom hook

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #29596

    Hi Brajesh

    I want to control and target profile fields groups individually with BP custom hooks.

    But how do I define each profile field group, can I use the group id, or group name for this?

    I found this markup, is this the way to go?

    Define custom hook:

    // Primary Group custom hook
    function custom_hook() {
    	do_action('custom_hook');
    }

    Tag custom hook

    <?php custom_hook(); ?>

    Add function

    <?php 
    function hello_wordpress() {
    	echo '<h1>Hello WordPress!</h1>';
    }
    add_action('custom_hook', 'hello_wordpress', 7);
    ?>

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #29612

    Hi Carsten,
    The above is correct way to create custom actions and attaching to those action.

    I am not sure what you want to accomplish, but it seems you want to display group data somewhere?

    To do that, you will need group id. If you want, you can pass group id as the 2nd parameter of the do_action function.

    PS:- If the goal is to only display fields data, creating custom hooks may not be needed.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #29616

    Hi Brajesh, thanks for your feed back.

    I have illustrated my goal, which is to place the edit buttons directly under their respective groups like this:

    https://imgur.com/QcsA51R

    Regards
    Carsten

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #29617

    Please disregard this topic, I think there is a plugin conflict going on

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #29620

    Sorry #29617 was added by mistake ‘Please disregard this topic, I think there is a plugin conflict going on’

    I still very much would like you to have a look at this

    I have illustrated my goal, which is to place the edit buttons directly under their respective groups like this:

    https://imgur.com/QcsA51R

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #29625

    Hi Carsten,
    If your goal is to add edit button under each group, there is an easy solution. You should override the profile loop template.

    you can copy buddypress/members/single/profile/profile-loop.php from your template pack or theme to your child theme/buddypress/members/single/profile/profile-loop.php

    That will give you all the flexibility.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #29628

    Hi Brajesh, yes, that is my goal, but of course it shall be the corresponding edit button for that group.

    ok, so after copying the profile-loop.php, how should I override it?

    What will that mean for the site functionality in general, overwriting this?

    Thanks
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #29631

    Template override is a p[referred way for any changes that you need in the UI.

    Which template pack are you using? Nouveau or legacy? I can post the code to show the edit button.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #29633

    Hi Brajesh, thanks

    I’m using Legacy

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #29634

    Thank you Carsten.

    Here is the code for profile-loop.php
    https://gist.github.com/sbrajesh/0ea24b0cafacaa098dbf8d61e5eda8be

    Please check the “Revision” tab there to see what I changed from the original file.

    Please let me know if it works for you or not?

    Regards
    Brajesh

The topic ‘ [Resolved] Creating a BP custom hook’ is closed to new replies.

This topic is: resolved