Skip to content

Instantly share code, notes, and snippets.

View wp-user-manager's full-sized avatar

wp-user-manager

View GitHub Profile
@wp-user-manager
wp-user-manager / wpum_block_first_last_name_same.php
Created December 16, 2023 19:10
WP User Manager - Stop registrations when the first and last name is the same
<?php
add_filter( 'submit_wpum_form_validate_fields', function ( $check, $fields, $values, $form_name ) {
if ( ! isset( $values['register']['user_firstname'] ) || empty( $values['register']['user_firstname'] ) ) {
return $check;
}
if ( ! isset( $values['register']['user_lastname'] ) || empty( $values['register']['user_lastname'] ) ) {
return $check;
}
@wp-user-manager
wp-user-manager / wpum_date_picker_format.php
Created March 15, 2023 21:42
WP User Manager - Change the display format of the Date field in the date picker
<?php
add_filter( 'wpum_field_datepicker_date_format', function (){
return 'd-m-Y';
});
@wp-user-manager
wp-user-manager / cover.php
Last active March 6, 2023 21:39
WPUM - Cover template for the profile which doesn't show the cover image but does show the avatar
<?php
/**
* The Template for displaying the profile cover.
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
@wp-user-manager
wp-user-manager / wpum_custom_field_regex_validation.php
Last active February 10, 2023 10:34
WP User Manager - Custom field validation server side with regex
<?php
add_filter( 'submit_wpum_form_validate_fields', function ( $check, $fields, $values, $form_name ) {
foreach ( $fields as $group_key => $group_fields ) {
$field_key = 'wpum_field_33'; // Change this to be your unique field ID with wpum_ prefix
if ( ! isset( $values[ $group_key ][ $field_key ] ) ) {
return $check;
}
@wp-user-manager
wp-user-manager / wpum_content_restriction_global_message.php
Created February 5, 2023 07:51
WP User Manager - Content Restriction - change the restriction message for all content unless they have a message specified
<?php
add_filter( 'wpumcr_global_restriction_message', 'my_wpum_global_restriction_message' );
function my_wpum_global_restriction_message( $restricted_global_message ) {
return 'This is message show for all restricted content unless the content has a specific restriction message.';
}
@wp-user-manager
wp-user-manager / wpum_content_restriction_function.php
Last active July 18, 2024 20:46
WP User Manager - Content Restriction function to restrict parts of a templat
<?php
get_header();
if ( wpum_can_access_restricted_content() ) : ?>
Some extra content in the template that is restricted as per the restriction settings of the page
<?php endif; ?>
<div>
<?php the_content(); ?>
</div>
<?php
add_filter( 'wpum_get_registration_fields', function ( $fields ) {
if ( isset( $fields['privacy'] ) ) {
unset( $fields['privacy'] );
}
return $fields;
} );
@wp-user-manager
wp-user-manager / wpum_likes_wp_query_order.php
Created January 2, 2023 22:05
WP User Manager - WP_Query ordering posts by the most likes
<?php
$args = array(
'post_status' => 'publish',
'post_type' => 'post',
'meta_key' => 'wpum_likes',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
@wp-user-manager
wp-user-manager / wpum_translate_profile_tab_slugs.php
Last active November 16, 2022 21:29
WP User Manager - Translate the profile URL slugs
<?php
function wpum_profile_tabs_translation_mapping() {
// Translated to Slovenian, change to your language
return array(
'about' => 'priblizno',
'posts' => 'objave',
'comments' => 'komentarj',
);
}
@wp-user-manager
wp-user-manager / wpum_allow_nickname_on_registration_form.php
Last active October 22, 2022 14:47
WP User Manager - Allow the nickname field to be added to registration forms
<?php
add_filter( 'wpum_non_allowed_fields', function ( $fields ) {
if ( ( $key = array_search( 'user_nickname', $fields ) ) !== false ) {
unset( $fields[ $key ] );
}
return $fields;
} );