Error: Permission denied message – login form instead?

This topic contains 4 reply and 2 voices, and was last updated by Tareq Hasan 10 years, 12 months ago
Viewing 4 Posts - 1 through 4 (of 4 total)
Author Posts
April 26, 2013 at 1:30 am 2883
Tareq Hasan Firstly - great plugin, really, really like where this is going. Quick question, if my client visits the page I have set up for them to view their project - if they are not already logged in, instead of simply getting a "Error: Permission denied" message displayed on the page, is it possible to display a login form? This kind of thing; But only if they are not already logged in. Know what I mean? Having this kind of functionality as part of the front-end for this plugin would be a great addition... :) Thanks, Jas
April 26, 2013 at 2:49 am 2885
jhkoning jhkoning

I’m no php programmer, but it’d be in header.php I’d imagine, somewhere around here;

`if ( !$pro_obj->has_permission( $project ) ) {
echo ‘

‘ . __( ‘Error: Permission denied’, ‘cpm’ ) . ‘

‘;
die();
}`

Where it may(?) be possible to add in a login form if the user isn’t already logged in?

April 26, 2013 at 4:56 am 2891
Tareq Hasan Tareq Hasan

I assume the problem you want to deal with the frontend version?

April 27, 2013 at 12:02 am 2921
jhkoning jhkoning

Hi Tareq,
Yes indeed – this is regards to the front end,
Jas

April 27, 2013 at 7:29 am 2930
Tareq Hasan Tareq Hasan

So may be you need to alter some code in the frontend plugins `frontend.php`. Replace the `shortcode` function with this:

[php]
function shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(‘id’ => 0), $atts ) );

if ( !$this->is_plugin_installed() ) {
return __( ‘Sorry, main plugin is not installed’, ‘cpmf’);
}

if ( $id ) {
$project_id = $id;
} else {
$project_id = isset( $_GET[‘project_id’] ) ? intval( $_GET[‘project_id’] ) : 0;
}

if ( !is_user_logged_in() ) {
return wp_login_form( array( ‘echo’ => false ) );
}

ob_start();
?>

<div class="cpm">
<?php
if ( $project_id ) {
$this->single_project( $project_id );
} else {
$this->list_projects();
}
?>
</div> <!– .cpm –>
<?php

return ob_get_clean();
}
[/php]

It’ll show login form if the user is not logged in.

Viewing 4 Posts - 1 through 4 (of 4 total)