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_rearrange_account_tabs.php
Created May 13, 2022 08:45
WP User Manager - Rearrange order of account page tabs
<?php
function my_wpum_rearrange_account_tabs( $tabs ) {
// Find the correct slug used in the URL, alter the priority
$tabs['email-subscriptions'] ['priority'] = 5;
return $tabs;
}
add_filter( 'wpum_get_account_page_tabs', 'my_wpum_rearrange_account_tabs', 100 );
@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_cover.php
Last active March 4, 2023 21:14
WP User Manager - Custom profiles/cover.php template to disable the display of the cover photo on the profile
<?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 February 4, 2023 00:04
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( 'account_page_form_fields', function ( $fields ) {
if ( ! wp_verify_nonce( $_POST['account_update_nonce'], 'verify_account_form' ) ) {
return $fields;
}
/**
* Changed this array to the field keys (wpum_ is the prefix)
*/
<?php
add_filter( 'wpum_get_registration_fields', function ( $fields ) {
if ( isset( $fields['privacy'] ) ) {
unset( $fields['privacy'] );
}
return $fields;
} );