Search Results for 'buddypress'
-
Search Results
-
Topic: PMPRO and Buddypress
Has anyone been successful at blocking buddypress pages until PMPRO email confirmation is complete? I seem to be getting nowhere with PMPRO folks.
I am able to block /groups/, /members/, etc., but I cannot seem to block the sub-pages (e.g. /groups/group-name/). I took the PMPRO email confirmation code and modified it as follows. Any help is greatly appreciated!
<?php
/*
Plugin Name: Paid Memberships Pro – Email Confirmation Add On
Plugin URI: http://www.paidmembershipspro.com/addons/pmpro-email-confirmation/
Description: Require email confirmation before certain levels are enabled for members.
Version: .3
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
Sample use case: You have a free level but want people to use a real email address when signing up.
*//*
[Deprecated] Set this array to the include the levels which should require email confirmation.global $pmpro_email_confirmation_levels;
$pmpro_email_confirmation_levels = array(6);Use the checkbox on the edit levels page instead.
*//*
Add checkbox to edit level page to set if level requires email confirmation.
*/
//show the checkbox on the edit level page
function pmproec_pmpro_membership_level_after_other_settings()
{
$level_id = intval($_REQUEST[‘edit’]);
if($level_id > 0)
$email_confirmation = get_option(‘pmproec_email_confirmation_’ . $level_id);
else
$email_confirmation = false;
?>
<h3 class=”topborder”>Email Confirmation</h3>
<table>
<tbody class=”form-table”>
<tr>
<th scope=”row” valign=”top”><label for=”email_confirmation”><?php _e(‘Email Confirmation:’, ‘pmpro’);?></label></th>
<td>
<input type=”checkbox” id=”email_confirmation” name=”email_confirmation” value=”1″ <?php checked($email_confirmation, 1);?> />
<label for=”email_confirmation”><?php _e(‘Check this to require email validation for this level.’, ‘pmpro’);?></label>
</td>
</tr>
</tbody>
</table>
<?php
}
add_action(‘pmpro_membership_level_after_other_settings’, ‘pmproec_pmpro_membership_level_after_other_settings’);//save email_confirmation setting when the level is saved/added
function pmproec_pmpro_save_membership_level($level_id)
{
if(isset($_REQUEST[’email_confirmation’]))
$email_confirmation = intval($_REQUEST[’email_confirmation’]);
else
$email_confirmation = 0;
delete_option(‘pmproec_email_confirmation_’ . $level_id);
add_option(‘pmproec_email_confirmation_’ . $level_id, $email_confirmation, ”, ‘no’);
}
add_action(“pmpro_save_membership_level”, “pmproec_pmpro_save_membership_level”);/*
Functions
*/
//Check if a level id requires an invite code or should generate one
function pmproec_isEmailConfirmationLevel($level_id)
{
global $pmpro_email_confirmation_levels;//get value from options
$email_confirmation = get_option(‘pmproec_email_confirmation_’ . $level_id, false);//check option and global var
return (!empty($email_confirmation) || !empty($pmpro_email_confirmation_levels) && in_array($level_id, $pmpro_email_confirmation_levels));
}//generate a key from a user id
function pmproec_getValidationKey($user_id)
{
$key = md5($user_id . AUTH_KEY . $user_id);
if(strlen($key) > 16)
$key = substr($key, 0, 16);return $key;
}/*
Save validation key in user meta after checkout.
*/
function pmproec_pmpro_after_checkout($user_id)
{
global $pmpro_level;if(pmproec_isEmailConfirmationLevel($pmpro_level->id))
{
//already validated?
$oldkey = get_user_meta($user_id, “pmpro_email_confirmation_key”, true);
if($oldkey != “validated”)
{
//nope? give them a key
$key = pmproec_getValidationKey($user_id);
update_user_meta($user_id, “pmpro_email_confirmation_key”, $key);
}
}
}
add_action(“pmpro_after_checkout”, “pmproec_pmpro_after_checkout”);/*
If a user hasn’t validated yet and needs it, don’t give them access.
*/
function pmproec_pmpro_has_membership_access_filter($hasaccess, $mypost, $myuser, $post_membership_levels)
{
//hide_buddy_press_pages()
$uri = $_SERVER[‘REQUEST_URI’];//lock some things for members only
$members_only = array(
“/members-2/”, “/activity/”, “/groups-2/”, “/forums/”, “/welcome-back/”
);
//if they don’t have access, ignore this
if(!$hasaccess)
return $hasaccess;//if this isn’t locked by level, ignore this
if(empty($post_membership_levels))
return $hasaccess;//does this user have a level that requires confirmation?
$user_membership_level = pmpro_getMembershipLevelForUser($myuser->ID);
if(pmproec_isEmailConfirmationLevel($user_membership_level->id))
{
//if they still have a validation key, they haven’t clicked on the validation link yet
$validation_key = get_user_meta($myuser->ID, “pmpro_email_confirmation_key”, true);if(!empty($validation_key) && $validation_key != “validated”)
{
$hasaccess = false;
foreach($members_only as $check)
{
//make sure they are a memberif(preg_match($check, $uri))
{
wp_redirect(“http://www.google.com”);
exit;
}
}
}
}
return $hasaccess;
}
add_filter(“pmpro_has_membership_access_filter”, “pmproec_pmpro_has_membership_access_filter”, 10, 4);/*
Add validation lik to confirmation email.
*/
function pmproec_pmpro_email_body($body, $email)
{
//must be a confirmation email and checkout template
if(!empty($email->data[‘membership_id’]) && pmproec_isEmailConfirmationLevel($email->data[‘membership_id’]) && strpos($email->template, “checkout”) !== false)
{
//get user
$user = get_user_by(“login”, $email->data[‘user_login’]);$validated = $user->pmpro_email_confirmation_key;
$url = home_url(“?ui=” . $user->ID . “&validate=” . $validated);//need validation?
if(empty($validated) || $validated != “validated”)
{
//use validation_link substitute?
if(false === stripos($body, “!!validation_link!!”))
{
$body = “<p>IMPORTANT! You must follow this link to confirm your email address before your membership is fully activated:<br />” . $url . “</p><hr />” . $body;
$body = str_replace(“Your membership account is now active.”, “”, $body);
} else
$body = str_ireplace(“!!validation_link!!”, $url, $body);
}
}return $body;
}
add_filter(“pmpro_email_body”, “pmproec_pmpro_email_body”, 10, 2);/*
Process validation links.
*/
function pmproec_init_validate()
{
if(!empty($_REQUEST[‘validate’]) && !empty($_REQUEST[‘ui’]))
{
$validate = $_REQUEST[‘validate’];
$ui = $_REQUEST[‘ui’];
$user = get_userdata($ui);
if($validate == $user->pmpro_email_confirmation_key)
{
//validate!
update_user_meta($user->ID, “pmpro_email_confirmation_key”, “validated”);do_action(‘pmproec_after_validate_user’, $user->ID, $validate);
if(is_user_logged_in())
wp_redirect(home_url());
else
wp_redirect(wp_login_url());exit;
}
}
}
add_action(“init”, “pmproec_init_validate”);/*
Update confirmation page to mention validation email if needed.
*/
function pmproec_pmpro_confirmation_message($message)
{
//must be an email confirmation level
if(!empty($_REQUEST[‘level’]) && pmproec_isEmailConfirmationLevel(intval($_REQUEST[‘level’])))
{
global $current_user;
if($current_user->pmpro_email_confirmation_key != “validated”)
{
$message = str_replace(“is now active”, “will be activated as soon as you confirm your email address. Important! You must click on the confirmation URL sent to ” . $current_user->user_email . ” before you gain full access to your membership“, $message);
}
}return $message;
}
add_filter(“pmpro_confirmation_message”, “pmproec_pmpro_confirmation_message”);/*
Function to add links to the plugin row meta
*/
function pmproec_plugin_row_meta($links, $file) {
if(strpos($file, ‘pmpro-email-confirmation.php’) !== false)
{
$new_links = array(
‘‘ . __( ‘Support’, ‘pmpro’ ) . ‘‘,
);
$links = array_merge($links, $new_links);
}
return $links;
}
add_filter(‘plugin_row_meta’, ‘pmproec_plugin_row_meta’, 10, 2);/**
* Add link to the user action links to validate a user
*
* Use the pmproec_validate_user_cap filter to change the capability required to see this.
*/
function pmproec_user_row_actions($actions, $user) {
$cap = apply_filters(‘pmproec_validate_user_cap’, ‘edit_users’);
if(current_user_can($cap))
{
//check if they still have a validation key
$validation_key = get_user_meta($user->ID, “pmpro_email_confirmation_key”, true);
if(!empty($validation_key) && $validation_key != “validated”)
{
$url = admin_url(“users.php?pmproecvalidate=” . $user->ID);
if(!empty($_REQUEST[‘s’]))
$url .= “&s=” . esc_attr($_REQUEST[‘s’]);
if(!empty($_REQUEST[‘paged’]))
$url .= “&paged=” . intval($_REQUEST[‘paged’]);
$url = wp_nonce_url($url, ‘pmproecvalidate_’ . $user->ID);
$actions[] = ‘Validate User‘;
}
else
$actions[] = ‘Validated’;
}return $actions;
}
add_filter(‘user_row_actions’, ‘pmproec_user_row_actions’, 10, 2);
add_filter(‘pmpro_memberslist_user_row_actions’, ‘pmproec_user_row_actions’, 10, 2);/**
* Manually validate a user. Runs on admin init. Checks for pmproecvalidate and nonce and validates that user.
*
*/
function pmproec_validate_user()
{
if(!empty($_REQUEST[‘pmproecvalidate’]))
{
global $pmproec_msg, $pmproec_msgt;//get user id
$user_id = intval($_REQUEST[‘pmproecvalidate’]);
$user = get_userdata($user_id);//no user?
if(empty($user))
{
//user not found error
$pmproec_msg = ‘Could not reset sessions. User not found.’;
$pmproec_msgt = ‘error’;
}
else
{
//check nonce
check_admin_referer( ‘pmproecvalidate_’.$user_id);//check caps
$cap = apply_filters(‘pmproec_validate_user_cap’, ‘edit_users’);
if(!current_user_can($cap))
{
//show error message
$pmproec_msg = ‘You do not have permission to validate users.’;
$pmproec_msgt = ‘error’;
}
else
{
//validate!
update_user_meta($user_id, “pmpro_email_confirmation_key”, “validated”);//show success message
$pmproec_msg = $user->user_email . ‘ has been validated.’;
$pmproec_msgt = ‘updated’;
}
}
}
}
add_action(‘admin_init’, ‘pmproec_validate_user’);/**
* Show any messages generated by PMPro Email Confirmations
*/
function pmproec_admin_notices()
{
global $pmproec_msg, $pmproec_msgt;
if(!empty($pmproec_msg))
echo “<div class=\”$pmproec_msgt\”><p>$pmproec_msg</p></div>”;
}
add_action(‘admin_notices’, ‘pmproec_admin_notices’);Topic: BuddyPress in Multi Site
I have a 2 site multisite. I put define ( ‘BP_ROOT_BLOG’, 2 ); for the secondary site to be in charge of BuddyPress.
But the Group Pages in the Admin Panel on the secondary site shows no groups and their pages. If I turn on BuddyPress in the main site, all the Group Pages show there.
The Groups listing shows up fine in the secondary site.
Is there a way to make the Group Pages show up in the secondary site?
Hi guys I have picked up on a bug where as any emails being sent are being shown as from wordpress and not from my website.
Being a custom website I would prefer users not to know that i’m using wordpress to run the website, plus it doesn’t look very professional.
I was using WP Better emails plugin which fixed this issue, but it conflicts with the buddypress built in email features so have had to disable it to make every thing work as it should.
Any ideas on how to show emails being sent as being sent from my website and not ‘wordpress’ ?
To get rid of the bbpress notice that appears at the top of the wp-admin screen for
Emails > Customize, paste this in yourtheme/functions.phpor in plugins/bp-custom.phpfunction pp_remove_bbpress_notice() { if ( isset( $_REQUEST['wp_customize'] ) ) { if ( class_exists( 'bbPress' ) ) { remove_action( 'set_current_user', 'bbp_setup_current_user', 10 ); add_action( 'set_current_user', 'pp_bbp_setup_current_user', 10 ); } } } add_action( 'plugins_loaded', 'pp_remove_bbpress_notice' ); function pp_bbp_setup_current_user() { if ( class_exists( 'bbPress' ) ) bbp_set_current_user_default_role(); }I posted a few challenges with the new email template UI here in ‘Ideas’, but it seems using
add_filter( 'bp_email_use_wp_mail', '__return_true' );to bypass the new email template feature, also causes BuddyPress (or WordPress) to bypass other Email html plugins (Namely, ‘WP Better Emails’).So, the new BP email template feature lacks the flexibility I need, but the bp_custom code to turn it off breaks my current html email solution (WP Better Emails).
Is there a different way to turn off the new email templates without bypassing other html email plugins?
Thanks!
BP & WP Current Versions. 2015 Theme.
Topic: BuddyPress Sub Nav
Topic: Filtering Activity Loops
Hey guys, I’ve never used buddy press before and before I dive in further I’d like to know if there is an option for users who sign up to create a post that could include text video images etc. When they are done their post they would then be able to choose 2-3 categories that their post fits in and then submit. When it gets submitted it would go to the activity loop on the home page under latest posts. Any other user who visits the site would be able to filter out all the posts created with a filter (similar to Kjiji or amazon) to find the exact posts they would like to see. Is this even possible or is this outside the scope of buddypress. Thanks in advance guys!
Topic: Visible profile fields
This appears to be a bit of a problem here, as there are others wondering why this is not a core function.
I am about to launch a forum for a school class. I need forum members to be able to see and recognise both the parent’s names and their child’s (it is not always obvious who sired which sprog).
I have set up a Child field in the extended profile, but I need that to be immediately available and visible along with the parent’s name, i.e.
Cuthbert Longstocking | Pippi LongstockingAny help out there (before BuddyPress improves itself)?
The forum page is here: Forum
And – BuddyPress – is there any way you could maybe get rid of the HTML formatting tags and display the text properly?!