Skip to content

Instantly share code, notes, and snippets.

@ituk
ituk / user-functions.php
Created May 18, 2020 16:57
wp-members modifictaions
<?php
/***** membership and subscription *****/
/** Change user role depending on expiration status, hooked to init when user is logged in **/
add_action( 'init', 'itamar_check_role_expiration__init' );
function itamar_check_role_expiration__init() {
// What are the role slugs for the two roles?
$active_member = 'memberfriend';
$expired_member = 'subscriber';
@ituk
ituk / php
Created May 13, 2020 10:19
Learndash: bypass course limitations for group leaders
/** Helper function to check if current user is a course group leader **/
function bayadaim_is_course_gl($course_id, $user_id){
$is_course_gl = false;
if($course_id == ''){
if ( empty( $post) ) {
global $post;
}
if( 'sfwd-lessons' === $post->post_type ){
$course_id = learndash_get_setting( $post, 'course' );
@ituk
ituk / save-post.php
Last active May 7, 2019 08:06
AccessPress create new user on post submission
/** ITUK's Register user on form submission
*
* OPEN `inc/core/save-post.php`.
* LOOK FOR LINE 179, it should be something like: `add_post_meta($post_id, 'ap_author_email', $author_email, false);`
* ADD THE FOLLOWING SNIPPET AFTER THAT LINE
*
**/
//if no user is registered with this email
if ( !email_exists($author_email) ){
function ituk_listing_register_user(){
if (isset($_POST['ap_form_submit_button'], $_POST['ap_form_nonce'])) { //this is returning false -> WHY?
//create new user from author email
if ( in_array('author_email', $_POST[ 'form_included_fields' ]) && $_POST[ 'ap_form_author_email' ] != '' ) {
$user_email = sanitize_email($_POST[ 'ap_form_author_email' ]);
$user_id = username_exists( $username );
//if no user is registered with this email