wpmem_securify

Description

This filter hook allows you to filter the $content container variable based on your own filter criteria.

This filter is part of the do_securify() function, which is a filter function hooked to the_content and runs at a priority of 99 (late).  The filter hook comes at the end of the function and will contain whatever is in the $content variable at that point. This may be the post content if unblocked or the user is logged in, or the login/registration form if the user is not logged in.

This filter can be used to add additional criteria for displaying content (such as levels, groups, or other individual user criteria), or it can be used to do additional filtering on the content as needed.

Parameters

$content
(string)(required) The $content variable after the do_securify() function has run.

$orig_content
(string)(optional) The original $content variable before being filtered.

Examples

The basic setup:

[snippet slug=wpmem_securify lang=php]

Here is a theoretical example where a custom user field “extra_access” is checked.  If the user is logged in, the content is blocked, and they do not have “1” as the “extra_access” value, then an error message is returned.

[snippet slug=wpmem_securify-example lang=php]

Changelog

  • Introduced in version 2.7.7
  • Moved to do_securify() in WP_Members object in 3.0.0

Source

wpmem_securify is located in includes/class-wp-members.php

Code Snippet Library [Subscriber Content]