Simple Membership Plugin › Forums › Simple Membership Plugin › Before login redirect
- This topic has 11 replies, 2 voices, and was last updated 8 years, 7 months ago by
mbrsolution.
-
AuthorPosts
-
April 27, 2018 at 3:47 pm #14304
juntgw
ParticipantHello,
I want to redirect to the login page if users directly accesses the membership page by bookmark.
Is that possible?April 27, 2018 at 9:42 pm #14307mbrsolution
ModeratorHi, please try the following addon/plugin. Let me know if this helps you.
Thank you
April 28, 2018 at 1:03 am #14310juntgw
ParticipantHi,
This add-on does not solve my problem.
When the user is not logged in, if he accesses the membership page, I want to redirect him to the login page.
Thank you
April 28, 2018 at 1:46 am #14311mbrsolution
ModeratorHi,
When the user is not logged in, if he accesses the membership page, I want to redirect him to the login page.
Are you talking about the Members profile page? If not can you let me know which page are you referring too.
Thank you
April 28, 2018 at 3:51 am #14312juntgw
ParticipantHi,
I am not good at English, I’m sorry I could not explain well.
I am talking about protected pages.
Thank you.
April 28, 2018 at 5:03 am #14313mbrsolution
ModeratorHi, thank you for clarifying further what you are trying to achieve. Please check the following documentation. Make sure you check the following title, test the code in question.
Check Current User’s Post Access Permission then Redirect User.
Let me know how you go.
Kind regards
April 28, 2018 at 9:33 am #14314juntgw
ParticipantHi,
Thank you kindly for your reply.
I checked the documentation and added code to function.php, but it does not work.
I wonder what’s wrong. . .April 28, 2018 at 9:56 am #14315mbrsolution
ModeratorHi, can you share here the php code you added to your functions.php file?
Thank you.
April 28, 2018 at 11:08 am #14316juntgw
ParticipantHi,
My site is here.
https://test0.pikule.jp/?
And login page ishttps://test0.pikule.jp/login/
Protected page (my-page) ishttp://test0.pikule.jp/my-page/If user access my-page when he is not logged in, I want to redirect him to the login page.
functions.php is is below.
—————-
<?php
/**
* Javo Themes functions and definitions
*
* @package WordPress
* @subpackage Javo
* @since Javo Themes 1.0
*/// Path Initialize
define( ‘JVFRM_SPOT_APP_PATH’ , get_template_directory() ); // Get Theme Folder URL : hosting absolute path
define( ‘JVFRM_SPOT_THEME_DIR’ , get_template_directory_uri() ); // Get http URL : ex)http://www.abc.com/
define( ‘JVFRM_SPOT_SYS_DIR’ , JVFRM_SPOT_APP_PATH.”/library”); // Get Library path
define( ‘JVFRM_SPOT_TP_DIR’ , JVFRM_SPOT_APP_PATH.”/templates”); // Get Tempate folder
define( ‘JVFRM_SPOT_ADM_DIR’ , JVFRM_SPOT_SYS_DIR.”/admin”); // Administrator Page
define( ‘JVFRM_SPOT_IMG_DIR’ , JVFRM_SPOT_THEME_DIR.”/assets/images”); // Images folder
define( ‘JVFRM_SPOT_WG_DIR’ , JVFRM_SPOT_SYS_DIR.”/widgets”); // Widgets Folder
define( ‘JVFRM_SPOT_HDR_DIR’ , JVFRM_SPOT_SYS_DIR.”/header”); // Get Headers
define( ‘JVFRM_SPOT_CLS_DIR’ , JVFRM_SPOT_SYS_DIR.”/classes”); // Classes
define( ‘JVFRM_SPOT_DSB_DIR’ , JVFRM_SPOT_SYS_DIR.”/dashboard”); // Dash Board
define( ‘JVFRM_SPOT_FUC_DIR’ , JVFRM_SPOT_SYS_DIR.”/functions”); // Functions
define( ‘JVFRM_SPOT_PLG_DIR’ , JVFRM_SPOT_SYS_DIR.”/plugins”); // Plugin folder
define( ‘JVFRM_SPOT_ADO_DIR’ , JVFRM_SPOT_SYS_DIR . “/addons”); // Addons folderdefine( ‘JVFRM_SPOT_CUSTOM_HEADER’, false );
// Includes : Basic or default functions and included files
require_once JVFRM_SPOT_SYS_DIR . “/define.php”; // defines
require_once JVFRM_SPOT_SYS_DIR . “/load.php”; // loading functions, classes, shotcode, widgets
require_once JVFRM_SPOT_SYS_DIR . “/enqueue.php”; // enqueue js, css
require_once JVFRM_SPOT_SYS_DIR . “/wp_init.php”; // post-types, taxonomies
require_once JVFRM_SPOT_ADM_DIR . “/class-admin-theme-settings.php”; // theme options
require_once JVFRM_SPOT_DSB_DIR . “/class-dashboard.php”; // theme screen options tab.$jvfrm_spot_core_include = apply_filters( ‘jvfrm_spot_core_function_path’, JVFRM_SPOT_APP_PATH .’/includes/class-core.php’ );
if( file_exists( $jvfrm_spot_core_include ) ) require_once $jvfrm_spot_core_include;
do_action( ‘jvfrm_spot_themes_loaded’ );
// update_option( ‘wp_less_cached_files’, ” );
if( !function_exists( ‘wcs_dequeue_quantity’ ) ) {
add_action( ‘wp_enqueue_scripts’, ‘wcs_dequeue_quantity’ );
function wcs_dequeue_quantity() {
wp_dequeue_style( ‘wcqi-css’ );
}
}if( !function_exists( ‘jvfrm_spot_custom_lava_listing_meta’ ) ) {
add_action( ‘lava_lv_listing_field_init’, ‘jvfrm_spot_custom_lava_listing_meta’ );
function jvfrm_spot_custom_lava_listing_meta( $field=”, $args=array() ) {
remove_filter( ‘lava_lv_listing_field_output’, ‘__return_false’, 99 );
if( in_array( $field, Array( ‘_logo’ ) ) ) {
add_filter( ‘lava_lv_listing_field_output’, ‘__return_false’, 99 );
}
}
}global $post;
$post_id = $post->ID;//Grab the post ID
$protection_ctrl = SwpmProtection::get_instance();
//Check if the current visitor has access to this post.
$is_protected = $protection_ctrl->is_protected($post_id);
if($is_protected) {
//This user doesn’t have permission to see this post. Redirect the user.
$redirect_url = ‘https://test0.pikule.jp/login/’;
wp_redirect($redirect_url);
exit;
}April 28, 2018 at 10:50 pm #14317mbrsolution
ModeratorHi, checking your code above and I noticed that the single quote was not typed correctly. Can you make sure you use the following code with the single quote typed correctly.
$redirect_url = 'https://test0.pikule.jp/login/';Give the above a try and let me know how you go.
Thank you
April 29, 2018 at 1:25 am #14320juntgw
ParticipantHi,
I typed the single quote correctly, but it does not work.
I also tried copy and pase, but the results were the same.April 29, 2018 at 1:34 am #14321mbrsolution
ModeratorHi, perhaps the other php code in your functions.php file is causing an issue. You might want to ask for paid support to further investigate this issue.
Kind regards
-
AuthorPosts
- You must be logged in to reply to this topic.