This topic has 8 replies, 2 voices, and was last updated 7 years by alexander.

  • Author
  • #169764
     alexander
    Participant

    Hello, i need to add a new button next to “New Message”, “Add Friend” to all users… i need to add it from functions.php, the button going to redirect to “Register” page with his name and ID…
    you can see it here:

    https://drnona.work/members/6/

    But i want the button to be visible to NOT logged in users only!

     

    Can you help me please?

    #169774
     Kieran_SQ
    Moderator

    Hi @alexander,

    You can always wrap your code in an !is_user_logged_in() statement which will then only run if the user is logged out.

    An example being

    COPY CODE
    if ( !is_user_logged_in() ) {
        // Your code here
    }

    You can see more about this function in the WordPress Codex https://developer.wordpress.org/reference/functions/is_user_logged_in/.

    Thanks,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #169777
     alexander
    Participant

    Hey, What about the button, how can i create one more button, similar to “Add Friend” or “Private messege” ?

    #169779
     Kieran_SQ
    Moderator

    Hi,

    Sorry, I got the impression you have already created the code to generate the button. Creating a custom register button that will pass the username and ID back into the register form will take a fair amount of time and coding, therefore it is beyond the scope of the support we can offer.

    You’ll either need to code this yourself or reach out to a developer to do this for you, you can also try emailing dev@seventhqueen.com with your idea to see if we have a developer available for you.

    To get you started you’ll need to look at bp_member_header_actions, you can find more about that here http://hookr.io/actions/bp_member_header_actions/. Currently there is no official BuddyPress Codex about this function.

    Thanks,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #169780
     alexander
    Participant

    No i have already created the button… i mean the code.. |
    All i need is to get the correct function action to place the button next to “Private message” button, and to have the same design.

    #169788
     Kieran_SQ
    Moderator

    Hi,

    I think I have gotten lost with what you currently have, please update this ticket with the code that you currently have.

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #169789
     alexander
    Participant

    Thats okay… i have fired it up 😛

    COPY CODE
    add_action('bp_member_header_actions', 'sq7_extra_fields_members_profile');
    function sq7_extra_fields_members_profile() {
    
       echo '<div id="send-private-message" class="generic-button"><a href="https://drnona.work/members/1281/messages/compose/?r=100500&_wpnonce=8d15c429b4" class="send-message">Private Message</a></div>';
    }
    #169790
     Kieran_SQ
    Moderator

    Hi,

    So I think I’m on the same page now, if I’m not I apologise!

    The below code will show a register button only if the user is logged out in the member header area

    COPY CODE
    // Register button in BuddyPress Member Header
    add_action('bp_member_header_actions', 'sq_register_field_members_profile');
    function sq_register_field_members_profile() {
    if ( !is_user_logged_in() ) {
       echo '<div id="user-register" class="generic-button"><a href="/register/" class="send-message">Register</a></div>';
    }
    }

    This should be added to your KLEO Child theme’s functions.php, adjust the login URL if needed.

    Thanks,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #169851
     alexander
    Participant

    Its great! thank you

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

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?