-
Author
-
August 6, 2017 at 12:31 #169764alexanderParticipant
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?
August 6, 2017 at 16:25 #169774Kieran_SQModeratorHi @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 CODEif ( !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 solutionIf 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.
August 6, 2017 at 16:34 #169777alexanderParticipantHey, What about the button, how can i create one more button, similar to “Add Friend” or “Private messege” ?
August 6, 2017 at 16:54 #169779Kieran_SQModeratorHi,
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 solutionIf 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.
August 6, 2017 at 16:56 #169780alexanderParticipantNo 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.August 6, 2017 at 17:24 #169788Kieran_SQModeratorHi,
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 solutionIf 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.
August 6, 2017 at 17:30 #169789alexanderParticipantThats okay… i have fired it up 😛
COPY CODEadd_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>'; }
August 6, 2017 at 17:50 #169790Kieran_SQModeratorHi,
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 solutionIf 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.
-
AuthorPosts
You must be logged in to reply to this topic.