In the case of moderated registration, where the user may not receive access to the site right away, you may find that you want to show the successful registration message, but eliminate the login form that shows below it by default. Here is a method to do that using the wpmem_login_form
filter.
Search Results for: short code
wpmem_restricted_msg
Description
This filters the post restricted message dialog.
The default message string is “<p>This content is restricted to site members. If you are an existing user, please log in. New users may register below.</p>”
Note that the message text can be customized in the plugin’s dialogs tab. Also, if you are running a translated version of the plugin, this string may likely be translated. Keep those things in mind if using this hook to use str_replace on any of the dialog text since str_replace will only work on an exact match.
Usage
/** * @param string $str The post restricted message with HTML. * @param string $msg The raw message string. * @param string $before The 'before' HTML wrapper. * @param string $after The 'after' HTML wrapper. */ add_filter( 'wpmem_restricted_msg', function( $str, $msg, $before, $after ) { /* * This example replaces the default <p> tag in the message * string with one containing a custom class. */ $str = str_replace( '<p>', '<p class="my-custom-class">', $str ); return $str; });
wpmem_login_redirect
Description
Filter hook to redirect the user upon login.
Parameters
$redirect_to
(string)(required) The URL to redirect the user to.
$user_id
(integer)(optional) The user’s primary key ID.
Usage
add_filter( 'wpmem_login_redirect', 'my_login_redirect', 10, 2 ); function my_login_redirect( $redirect_to, $user_id ) { // This will redirect to https://yourdomain.com/your-page/ return home_url( '/your-page/' ); }
Notes
In plugin version 3.1.7, the WordPress login_redirect hook was added to login function. A filter for login_redirect would run on all logins across the site (whether from the WP-Members form or any other login form). A filter for wpmem_login_redirect would run only from the WP-Members login forms.
In order of operations, the login_redirect filter is applied first, then wpmem_login_redirect.
Changelog
- Introduced in 2.7.7
- $user_id argument added in 2.9.2
- login_redirect added to login function in 3.1.7
Source
wpmem_login_redirect is located in includes/class-wp-members-user.php
Custom Email Content
There are several emails that may go to users. These include:
- New Registration – notifies the user that they have successfully registered.
- Registration is Moderated – notifies the user that their registration is pending admin approval.
- Registration is Moderated, User is Approved – notifies the user their pending registration is now approved.
- Password Reset – email to send a new password to a user that forgot their password.
- Admin Notification – email to admin notifying them of each newly registered user.
- Email Signature – a footer or signature placed at the bottom of each of the above emails.
In addition to being able to set custom static content in these emails via the plugin’s admin panel, there are also filter hooks for each email sent out. Filter hooks allow you to filter the email that is sent and also to add/subtract content from the email based on additional criteria. The following filter hooks are available for email content:
- wpmem_email_filter (powerful, all-encompassing filter for all but the admin notification email. see documentation for a list of all parameters the filter handles)
- wpmem_email_newreg
- wpmem_email_newmod
- wpmem_email_appmod
- wpmem_email_repass
- wpmem_email_notify
- wpmem_email_headers
- wpmem_email_shortcodes
- wpmem_notify_addr (changes the admin notification email address programmatically – can be used for different email addresses as well as multiple recipients)
- wpmem_notify_filter (admin notification email filter equivalent to wpmem_email_filter)
Customizing Emails
Using the plugin’s administration panel, you may customize the content of the email messages that are sent by the plugin.
Note: only the emails relevant to your settings will display in the admin panel. For example, if you are not moderating registrations, the email for an admin approved registration will not display since you do not use it.