hemligg
Forum Replies Created
-
Forum: Plugins
In reply to: [Verified Member for BuddyPress] I want to automate some thingsThis is works better:
public function save_meta_box() {
if ( $this->can_save() ) {
if ( ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
$user_id = intval( $_GET['user_id'] );
} else {
$user_id = get_current_user_id();
}
// Get current value of 'bp_verified_member'
$existing_value = get_user_meta($user_id, $this->meta_keys['verified'], true);
$new_value = ! empty($_POST[$this->meta_keys['verified']]);
// If the meta key does not exist, add it first with the opposite value
if ($existing_value === '') {
add_user_meta($user_id, $this->meta_keys['verified'], '');
}
// Now force an update, which will triggerbefore_update_user_meta
update_user_meta($user_id, $this->meta_keys['verified'], $new_value);
}
}Forum: Plugins
In reply to: [Verified Member for BuddyPress] I want to automate some thingsWell that hook will not work unless the user already has a row in the usermeta database table with meta_key ‘bp_verified_member’. If that row is missing the action ‘bp_verified_member_verified_status_updated’ will never be triggered.
In order to get it to work you need to replace the function save_meta_box() in the file class-bp-verified-member-meta-box.php with this:
public function save_meta_box() {
if ( $this->can_save() ) {
if ( ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
$user_id = intval( $_GET['user_id'] );
} else {
$user_id = get_current_user_id();
}
// Get current value of 'bp_verified_member'
$existing_value = get_user_meta($user_id, $this->meta_keys['verified'], true);
$new_value = ! empty($_POST[$this->meta_keys['verified']]);
if ($existing_value === '') {
// Manually triggerbefore_update_user_meta
do_action('before_update_user_meta', null, $user_id, $this->meta_keys['verified'], $new_value);
// Now add the meta since it doesn’t exist
add_user_meta($user_id, $this->meta_keys['verified'], $new_value);
} else {
// Normal update, which will triggerbefore_update_user_meta
update_user_meta($user_id, $this->meta_keys['verified'], $new_value);
}
}
}Forum: Plugins
In reply to: [Invite Anyone] Massive number of PHP Warnings after update to PHP 8.1Well actually we now found that this code isn’t working. Users could access the invite page and send invitations even though only Administrators should have access.
So it seems the role to be used should be ‘minimum_role’ and not ’email_role’.
So the function invite_anyone_access_test() we use now in file /invite-anyone/by-email/by-email.php is the following:
function invite_anyone_access_test() {
global $current_user, $bp;
$access_allowed = true;
$iaoptions = invite_anyone_options();
if ( ! is_user_logged_in() ) {
$access_allowed = false;
} elseif ( current_user_can( 'bp_moderate' ) ) {
// The site admin can see all
$access_allowed = true;
} elseif ( bp_displayed_user_id() && ! bp_is_my_profile() ) {
$access_allowed = false;
} elseif ( isset( $iaoptions['email_visibility_toggle'] ) && 'no_limit' === $iaoptions['email_visibility_toggle'] ) {
// This is the last of the general checks: logged in,
// looking at own profile, and finally admin has set to "All Users".
$access_allowed = true;
} elseif ( isset( $iaoptions['email_since_toggle'] ) && 'yes' === $iaoptions['email_since_toggle'] ) {
// Minimum number of days since joined the site
$since = isset( $iaoptions['days_since'] ) ? $iaoptions['days_since'] : 0;
if ( $since ) {
// WordPress's DAY_IN_SECONDS exists for WP >= 3.5, target version is 3.2, hence hard-coded value of 86400.
$since = $since * 86400;
$date_registered = strtotime( $current_user->data->user_registered );
$time = time();
if ( $time - $date_registered < $since ) {
$access_allowed = false;
}
}
} elseif ( isset( $iaoptions['email_role_toggle'] ) && 'yes' === $iaoptions['email_role_toggle'] ) {
// Check if 'email_role' is set before accessing it.
if ( isset( $iaoptions['minimum_role'] ) && ! empty( $iaoptions['minimum_role'] ) ) {
$role = $iaoptions['minimum_role'];
// Minimum role on this blog. Users who are at the necessary role or higher
// should move right through this toward the 'return true' at the end of the function.
if ( isset( $iaoptions['minimum_role'] ) && $role ) {
switch ( $role ) {
case 'Subscriber' :
if ( ! current_user_can( 'read' ) ) {
$access_allowed = false;
}
break;
case 'Contributor' :
if ( ! current_user_can( 'edit_posts' ) ) {
$access_allowed = false;
}
break;
case 'Author' :
if ( ! current_user_can( 'publish_posts' ) ) {
$access_allowed = false;
}
break;
case 'Editor' :
if ( ! current_user_can( 'delete_others_pages' ) ) {
$access_allowed = false;
}
break;
case 'Administrator' :
if ( ! current_user_can( 'switch_themes' ) ) {
$access_allowed = false;
}
break;
}//end switch
}//end if
}
}
elseif ( isset( $iaoptions['email_blacklist_toggle'] ) && 'yes' === $iaoptions['email_blacklist_toggle'] ) {
// User blacklist.
if ( isset( $iaoptions['email_blacklist'] ) ) {
$blacklist = wp_parse_id_list( $iaoptions['email_blacklist'] );
$user_id = intval( $current_user->ID );
if ( in_array( $user_id, $blacklist, true ) ) {
$access_allowed = false;
}
}
}
return apply_filters( 'invite_anyone_access_test', $access_allowed );
}- This reply was modified 3 months ago by hemligg.
Forum: Plugins
In reply to: [NSFW] [Simple Event Planner] Some users get calendar displayed incorrectlyWell it turned out it was a css issue and not a javascript issue.
I added the following css code and that seemed to have solved the issue:
/* Ensure that every day has consistent borders */
.sep-page .sep-calendar .eventCalendar-wrap .eventCalendar-slider .eventCalendar-monthWrap .eventCalendar-daysList.eventCalendar-showAsWeek .eventCalendar-day {
display: inline-block;
width: calc(100% / 7); /* Each day takes 1/7th of the row */
box-sizing: border-box; /* Ensure padding/border is included in the width */
border-right: solid 1px #ececec; /* Add right border to separate days */
border-bottom: solid 1px #ececec; /* Add bottom border */
}
/* Ensure that the last day of the week doesn't have a right border */
.sep-page .sep-calendar .eventCalendar-wrap .eventCalendar-slider .eventCalendar-monthWrap .eventCalendar-daysList.eventCalendar-showAsWeek .eventCalendar-day:nth-child(7n) {
border-right: none; /* No right border for Sunday */
}
/* Add a top border to the second row to ensure separation */
.sep-page .sep-calendar .eventCalendar-wrap .eventCalendar-slider .eventCalendar-monthWrap .eventCalendar-daysList.eventCalendar-showAsWeek .eventCalendar-day:nth-child(n+8) {
border-top: solid 1px #ececec; /* Add top border for the second row */
}
/* Ensure that the first day of the week (Monday) starts with a clean left border */
.sep-page .sep-calendar .eventCalendar-wrap .eventCalendar-slider .eventCalendar-monthWrap .eventCalendar-daysList.eventCalendar-showAsWeek .eventCalendar-day:nth-child(7n+1) {
border-left: solid 0px #ececec; /* Remove left border for Monday */
}
.sep-page .sep-calendar .eventCalendar-wrap .eventCalendar-slider .eventCalendar-monthWrap .eventCalendar-daysList.eventCalendar-showAsWeek .eventCalendar-day {
width: calc(100% / 7); /* Ensure each day takes 1/7th of the row */
min-width: 14%; /* Fallback for older browsers */
box-sizing: border-box; /* Include padding/border in the width calculation */
}
/* Ensure the list container does not overflow */
.sep-page .sep-calendar .eventCalendar-wrap .eventCalendar-slider .eventCalendar-monthWrap .eventCalendar-daysList {
overflow: hidden;
}Forum: Plugins
In reply to: [NSFW] [Simple Event Planner] Some users get calendar displayed incorrectlyWell it seems the fix didn’t work after all. The users that experience the issue reports the issue remain. So I’m trying another fix now. I’ll get back to you if that solves the problem.
Forum: Plugins
In reply to: [NSFW] [Simple Event Planner] Some users get calendar displayed incorrectlyWell we have solved the issue on our site by override the file jquery.eventCalendar.min.js in our child theme to force the the calender to always be generated as a Monday-to-Sunday-calendar.
This was done by replacing the following code:
for (n.startWeekOnMonday && (w = dt.getDay() - 1), 0 > w && (w = 6), C = w; C > 0; C--) { u.push('<li class="eventCalendar-day eventCalendar-empty"></li>'); }
with the following code:
// Adjust to always start on Monday
if (n.startWeekOnMonday) { w = (w === 0) ? 6 : w - 1;
}
for (C = w; C > 0; C--) {
u.push('<li class="eventCalendar-day eventCalendar-empty"></li>');
}We also increased the default limit of the number of events listed below the calendar from 4 to 30. But that was another issue. ??
The issue of the calendar being generated wrongly in some cases was something we never were able to replicate ourselves but got reports about from users. But as we never need to have the calendar in any other way than Monday to Sunday we could solve the issue without solving the real issue.
But I hope you got some clues from this.
Forum: Plugins
In reply to: [Simple Event Planner] Calendar shows only 6 eventsThe default limit is 5. So you need to increase this to but adding events_limit to the the shortcode like this [event_calendar search=”false” events_limit=”50″ ] if you have up to 50 events per month.
It will still only list maximum 4 events beneath the calendar thought. Because that default value is set to 4 which is set by a javascript. To change that you will need to change that in the javascript file jquery.eventCalendar.min.js and override it in your child theme. Which is a hassle. I would have prefered to be able to set that default value in an easier way.
Forum: Plugins
In reply to: [NSFW] [Simple Event Planner] Some users get calendar displayed incorrectlyIf you have a hard time seeing the issue on this screenshot I provided I can point out that the box for Monday 7th is blank and the 7 is put on Tuesday and 8 on Wednesday and so on.
We have had another user reporting this issue now. This time the user used Edge on a pc. But he got it right when checking the same thing on his phone.
Okay. Thanks. I haven’t received any email. Maybe I accidently wrote wrong email address. I’ll open a ticket again and make sure I enter correct email address.
I can add that it seems if I run the page in an incognito tab in Chrome then it stops working in Chrome as well.
I’ve opened a ticket now with the url and password.
Yes I can share an url. But since it is on a password protected staging site I rather not share it openly. ??
I have now done some further testing with other themes and browsers. And it seems to be working always in Chrome. But it doesn’t work in Firefox, Edge, Safari or DuckDuckGo. And it isn’t an issue isolated to the theme we are using. The same issue is in all themes I have tested.
I have reviewed this further and found that the error is caused by a conflict with the plugin BuddyPress Member Blog by WbCom. And the reason for that seems to be that both your plugin and their plugin is using the javascript plugin Selectize.
I don’t know who is to blame. If it is you or them. But I guess either you or them will need to do something about it.
Forum: Plugins
In reply to: [BP Profile Search] undefined array key “HTTP_REFERER” in…The filter is applied on all pages. We are using the GET method.