Forum Replies Created
-
In reply to: BP template hierarchy Codex article
@bphelp thanks, I was going to do that but wanted to make sure it was a typo before updating. Didn’t want to dive in and change something that could have been right already 🙂
In reply to: BP template hierarchy Codex articleI thought that is what could have happened 🙂
@shanebp lol. There must be a plugin out there somewhere 🙂
Uh?
So after they register the page would say something like ‘welcome, here is your challenge ID’
@aducale OK. In that case
<?php echo bp_loggedin_user_id(); ?>would work so long as the user is logged in when viewing the page.@shanebp I think the OP just needs a unique numerical?
Each new member automatically gets assigned a numerical ID which you can use for this purpose.
<?php echo bp_loggedin_user_id(); ?>will display it on screen for the user if they are logged in.In reply to: Disallow HTML tags in profile fieldsfound it
bp_get_profile_field_dataIn reply to: Delete post comments via front endThanks @mercime – wish you told me about that plugin yesterday. Spent about 5 hours getting my code to work – the problem was all down to the “headers already sent”. You have to redirect early on (around the wp_loaded action) – before the headers are sent or you’ll hit problems like I did.
I’ve been using the rtMedia plugin by rtCamp. You’d be able to do everything you mentioned using that.
In reply to: Delete post comments via front endJust to add (if anyone is interested), to have the page reload i’m using this as the last line in my function
wp_safe_redirect( wp_get_referer() ); exit;In reply to: Delete post comments via front endGot it! I had to turn my form processing code into a function and hook it to the wp_loaded action. This avoided getting the dreaded “headers already sent” error.
In reply to: Delete post comments via front endOK my code so far which partially works. I just need the page to reload or refresh to reflect that the comment has been deleted from the database. Any ideas?
if ( isset( $_POST['comment_delete_nonce'] ) ) { if( wp_verify_nonce( $_POST['comment_remove_nonce'], 'comment-remove-nonce' ) ) { set_query_var( 'commentid1', $_POST['commentid'] ); wp_delete_comment( get_query_var( 'commentid1'), true ); } }HTML form:
<form method="POST" action="" class="delete-comment-form"> <input type="hidden" name="comment_remove_nonce" value="<?php echo wp_create_nonce('comment-remove-nonce'); ?>" /> <input type="hidden" name="commentid" value="<?php comment_ID() ?>" /> <input type="submit" value="Delete" title="Delete" id="submit-btn" class="btn" /> </form>Thanks!
Just out of interest, if I use the capabilities page to mark a user as a spammer, what does that actually do? Delete the user from the site? Banish them into a black hole? etc
That’s what I thought it was for. Thanks for verifying @mercime – I was half thinking such capability settings would be performed via the backend dashboard – but of course this is BuddyPress – for front end stuff! 🙂
In reply to: Blog URLs – multisitebump
In reply to: Private Portal with BuddyPressHi @mossyoak
I’ve run a few tests and made some slight changes to that code. Try this
function bp_my_restrict() { $user_id = bp_loggedin_user_id(); $user = new WP_User( $user_id ); if ( ( $user->roles[0] != 'administrator' ) ) { if ( bp_is_current_component('members') || bp_is_current_component('activity') ) { wp_redirect( home_url() ); exit(); } } } add_action('wp','bp_my_restrict');These components already have their own pages.
As examples, try visiting:
yourwebsite.com/activity
yourwebsite.com/membersIn reply to: Private Portal with BuddyPressJust read through your original question. The code snippet you’d want to add to your theme’s functions.php is something like this:
function bp_my_restrict() { global $bp; $user_id = bp_loggedin_user_id(); $user = new WP_User( $user_id ); if ( bp_is_current_component('members') || bp_is_current_component('activity') ) { if ( ( $user->roles[0] != 'administrator' ) ) { wp_redirect( $bp->loggedin_user->domain ); exit(); } } } add_action('wp','bp_my_restrict');In reply to: Private Portal with BuddyPressTry this
<?php $user_id = bp_loggedin_user_id(); $user = new WP_User( $user_id ); if ( $user->roles[0] != 'administrator' ) { // your code } ?>In reply to: Private Portal with BuddyPressYou could use the WordPress conditional
is_page()to check if the user is on the activity or members page:if ( is_page('members') || is_page('activity') ) { } else { }Note: I’m assuming you haven’t changed the default slugs
In reply to: Show members with certain roleIt is easily done. You’d need to create a new page template:
https://codex.wordpress.org/Page_Templates
You can then use a modified members loop inside the page template you create:
In reply to: Show members with certain role<?php $user_id = bp_get_member_user_id(); $user = new WP_User( $user_id ); if ( $user->roles[0] != 'editor' ) break; ?>That’ll display only editors
In reply to: Show members with certain role<?php $user_id = bp_get_member_user_id(); $user = new WP_User( $user_id ); if ( $user->roles[0] == 'editor' ) break; ?>If you add that code directly below
while ( bp_members() ) : bp_the_member();you’ll get a list of members who are not editors.